想象一个应用程序,其中 Activity A 是默认 Activity 并且具有 launchMode="singleTask"。应用程序打开到 Activity A。用户在应用程序中导航,并在某个时候再次导航到 Activity A(通过向前移动,而不是按下后退)。根据 Android 文档,因为 launchMode="singleTask",这将发生:
The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.
Activity A 存在于返回栈中,因此它会收到对 onNewIntent() 的调用。我想知道的是,当 Activity A 从返回堆栈底部移至顶部时,其他 Activity 会发生什么情况?
它们是被弹出并销毁还是发生了其他事情?它们甚至在同一个堆栈中吗?
提前致谢...
最佳答案
来自 Android 文档: http://developer.android.com/images/fundamentals/diagram_backstack_singletask_multiactivity.png
表示如何将启动模式为“singleTask”的 Activity 添加到返回堆栈。如果该 Activity 已经是具有自己的返回堆栈的后台任务的一部分,那么整个返回堆栈也会出现在当前任务之上。
关于android - 当 launchMode ="singleTask"重新打开 Activity 时,返回堆栈会发生什么情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21035299/