android - 当 launchMode ="singleTask"重新打开 Activity 时,返回堆栈会发生什么情况?

标签 android android-intent android-activity

想象一个应用程序,其中 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/

相关文章:

android - 在 Activity 中正常膨胀时在服务中膨胀 View 时膨胀异常

android - 为什么 float 操作按钮在 BottomBar 后面

android - HTTP 发布请求 : Error 400, Firebase 主题消息

android - 限制发送可以向我的应用发送 ACTION_SEND Intent 的应用

android - 删除图像文件后刷新图库?

android - 当 "activity not found to handle intent"时,是否有 Android 应用程序通过查看 Play 商店来解决 Intent ?

android - 如何在 java 代码中管理 UI?

android - 如何在 Android 上运行 ProGuard 测试?

android - 在 getjar.com 上推送 Android 应用程序更新

java - Android Sharing Intent 仅适用于 Google Photos,会导致其他应用程序崩溃