I am trying to wrap my head around the different options of Android's Activity launch mode (See documentation: Tasks and Back Stack

According to the documentation, when launching an activity that is marked as "singleTask":

"... Instead, either a new task starts for the Browser or, if the Browser already has a task running in the background, that task is brought forward to handle the new intent."

According to the way singleTask is described, either a new task is created, or, if the activity already exists in some other task, that task is brought forward.

What happens in case an instance of the Browser activity (for example) already exists in the same task (stack) of my app's activity (but not in the foreground) ? How is it brought forward? This is not described in the doc.

有帮助吗?

解决方案

You asked:

What happens in case an instance of the Browser activity (for example) already exists in the same task (stack) of my app's activity (but not in the foreground) ? How is it brought forward? This is not described in the doc.

It is not possible for an instance of the Browser activity (to use your example) to exist in your app's task stack, because that Activity has been defined with singleTask launch mode and has a different taskAffinity from the other activities in your app. Therefore, whenever the Browser activity is launched, it will always be launched into its own task, and not into your task.

其他提示

"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.

Note: SingleTask and SingleInstance are used for specialized launches . It is not recommended for general use

From this link http://developer.android.com/guide/topics/manifest/activity-element.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top