本文介绍了是的onStop()总是调用一次的onPause()被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可能在onPause()被调用,然后紧接着,onResume()被称为?换句话说,做活动总是要经过的onStop(),在onStart(),然后它的onPause()被调用onResume()后?

Is it possible that onPause() is called, and then immediately after that, onResume() is called? In other words, does the activity always has to go through onStop(), onStart() and then onResume() after its onPause() is called?

活动的生命周期文件说,这是可能的,但是这将是用户的动作来触发?任何人都可以创建活动JUnit测试证明?

The activity lifecycle document says it is possible, but what would be the user actions to trigger that? Can anyone create an activity JUnit test to demonstrate that?

推荐答案

是的,这是的onPause常见() - > onResume() - > 的onPause() - > onResume()发生周期

Yes, it is common for onPause() -> onResume() -> onPause() -> onResume() cycle to occur.

查看文档。

如果一个活动是完全被遮挡(被其他活动)后它可能会被停止,但如果它仅部分由其他活动(设置一个对话框的主题,例如)遮蔽,那么它只会被暂停,然后继续当弹出活动关闭。

If an Activity is totally obscured (by another Activity for example) it will likely be stopped but if it is only partly obscured by another Activity (set with a dialog theme, for example), then it will simply be paused and then resumed when the 'popup' Activity is closed.

这篇关于是的onStop()总是调用一次的onPause()被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 23:05