上面提到的文档(http://developer.android.com/training/basics/activity-lifecycle/stopping.html)声明如下:
There are a few of key scenarios in which your activity is stopped and restarted:
The user opens the Recent Apps window and switches from your app to another app. The activity in your app that's currently in the foreground is stopped. If the user returns to your app from the Home screen launcher icon or the Recent Apps window, the activity restarts.
但在调试过程中,我发现当我启动“最近的应用程序”窗口时,我的 Activity 中被覆盖的 onStop()
被调用。因此,仅启动此窗口会使 Activity 停止,而不是用户需要切换到文档中当前所述的另一个应用程序。
这是 Android 文档错误吗?
最佳答案
不,这不是错误 - 该点中的最后一句话指出:
If the user returns to your app from the Home screen launcher icon or the Recent Apps window, the activity restarts.
(我的粗体)
声明(有点笨拙)如果用户从“最近使用的应用程序”窗口返回, Activity 将重新启动,暗示启动“最近使用的应用程序”窗口将停止 Activity 。
标题中有一点说明:
When the user leaves your activity, the system calls
onStop()
to stop the activity
因此,通过转到“最近的应用程序”窗口,您已离开该 Activity ,因此系统调用 onStop()
关于android - android文档错误 'Stopping and Restarting an Activity',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28658850/