为什么次要活动也将重返主力活动时,被破坏?也将、主力

2023-09-12 05:57:03 作者:千寻

在回去活性的(主要活动)活动B被破坏。为什么是这样?

When going back to activity A (main activity) the activity B is being destroyed. Why is that happening?

该示例程序我想了解的是在这里: http://developer.android.com/shareables/training/ActivityLifecycle.zip

The example program I'm trying to understand is here: http://developer.android.com/shareables/training/ActivityLifecycle.zip

推荐答案

这里有一个如何在任务中每一个新的活动增加了一个项目后面堆了重新presentation。当用户presses后退按钮,当前的活动被破坏,previous活动恢复。

Here's a representation of how each new activity in a task adds an item to the back stack. When the user presses the Back button, the current activity is destroyed and the previous activity resumes.

为什么要破坏?因为最新的活动是在堆栈的顶部,并获得到下一个活动,你弹出最新的关闭(的 LIFO )。更多信息此处 。

Why destroyed? Because the latest activity is on top of the stack and to get to the next activity, you pop the latest off (LIFO). More info here.