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.
Regardless of whether an activity starts in a new task or in the same task as the activity that started it, the Backbutton always takes the user to the previous activity. However, if you start an activity that specifies thesingleTask
launch mode, then if an instance of that activity exists in a background task, that whole task is brought to the foreground. At this point, the back stack now includes all activities from the task brought forward, at the top of the stack.
如果SingleTask的Activity没有启动,那么会新建一个Task并在这个Task中启动这个Activity,如果在其他Task中已经有这个SingleTask的Activity的实例,那么会合并这两个Task
SingleInstance:
Same as "singleTask"
, except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task; any activities started by this one open in a separate task.
和SingleTask一样,只是Task中有且只有这个SingleInstance的Activity