具有 'singleTask' 启动模式的 activity 如何在任务中不是 root activity?
How can an activity with 'singleTask' launch mode be not root activity in a task?
这是来自 android 文档的图像:
Activity Y有'singleTask'启动模式但在任务中不是root activity,即Activity X。怎么会这样?
更新:
"singleTask"
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.
Note: Although the activity starts in a new task, the Back button still returns the user to the previous activity.
Single task only 表示这个activity只能创建一次 cf to this website: http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
activity 是不是 root 并不重要
singleTask:
This mode is quite different from standard and singleTop. An Activity
with singleTask launchMode is allowed to have only one instance in the
system (a.k.a. Singleton). If there is an existed Activity instance in
the system, the whole Task hold the instance would be moved to top
while Intent would be delivered through onNewIntent() method.
Otherwise, new Activity would be created and placed in the proper
Task.
我认为答案是这个 activity 是在带有 FLAG_ACTIVITY_SINGLE_TOP
标志的意图下启动的,因为意图比 xml 标签具有更高的优先级。
这是来自 android 文档的图像:
Activity Y有'singleTask'启动模式但在任务中不是root activity,即Activity X。怎么会这样?
更新:
"singleTask"
The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time. Note: Although the activity starts in a new task, the Back button still returns the user to the previous activity.
Single task only 表示这个activity只能创建一次 cf to this website: http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
activity 是不是 root 并不重要
singleTask:
This mode is quite different from standard and singleTop. An Activity with singleTask launchMode is allowed to have only one instance in the system (a.k.a. Singleton). If there is an existed Activity instance in the system, the whole Task hold the instance would be moved to top while Intent would be delivered through onNewIntent() method. Otherwise, new Activity would be created and placed in the proper Task.
我认为答案是这个 activity 是在带有 FLAG_ACTIVITY_SINGLE_TOP
标志的意图下启动的,因为意图比 xml 标签具有更高的优先级。