根据文档,“onPause”在以下情况下被调用:
when the system is about to start resuming a previous activity.
与“onStop”相比,区别在于:
Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one.
但是当我长按 HW-Home 键时,“最近的应用程序”出现了, 不调用“onPause”。
此刻,我无法再与原来的 Activity 互动, 但它仍然可见。
我对这种情况感到困惑。 请帮忙解释一下。
非常感谢。 BR, 亨利
最佳答案
这实际上发生了,因为当 Home 键被长按时,没有启动任何 Activity。 onPause/onStop 只有在您选择“最近使用的应用程序”列表中的应用程序之一时才会被调用。
onPause() 的文档非常清楚:
Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed.
关于android - 为什么在以下情况下不调用 "onPause"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9226027/