【问题标题】:What happens to the back stack when re-opening an activity when launchMode="singleTask"?当 launchMode="singleTask" 重新打开一个活动时,后台堆栈会发生什么?
【发布时间】:2014-01-10 02:42:15
【问题描述】:

想象一个应用,其中 Activity A 是默认 Activity,并且具有 launchMode="singleTask"。应用程序打开到 Activity A。用户在应用程序中导航,并在某个时候再次导航到 Activity A(通过向前移动,而不是向后按下)。根据 Android 文档,因为 launchMode="singleTask",会发生这种情况:

系统在新任务和路由的根目录创建活动 它的意图。但是,如果活动的一个实例已经 存在,系统通过 调用它的 onNewIntent() 方法,而不是创建一个新方法。

Activity A 存在于后栈中,因此它会收到对 onNewIntent() 的调用。我想知道的是,当 Activity A 从后端堆栈的底部移到顶部时,其他 Activity 会发生什么?

它们是被弹出并销毁还是发生了其他事情?它们甚至在同一个堆栈中吗?

提前谢谢...

【问题讨论】:

  • 您好,您看到答案了吗?如果是并且对您来说可行,那么问题将被关闭,我们将在解决后转到下一个问题。 :)

标签: android android-intent android-activity


【解决方案1】:

来自 Android 文档: http://developer.android.com/images/fundamentals/diagram_backstack_singletask_multiactivity.png

A representation of how an activity with launch mode "singleTask" is added to the back stack. If the activity is already a part of a background task with its own back stack, then the entire back stack also comes forward, on top of the current task.

【讨论】:

    猜你喜欢
    • 2020-07-21
    • 1970-01-01
    • 2014-11-04
    • 2010-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-20
    • 2013-06-22
    相关资源
    最近更新 更多