- "standard" (the default mode)
Default. The system creates a new instance of the activity in the task from which it was started and routes the intent to it. The activity can be instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances.
每一次都會(huì)重新創(chuàng)建一個(gè)實(shí)例
- "singleTop"
If an instance of the activity already exists at the top of the current task, the system routes the intent to that instance through a call to its onNewIntent()
method, rather than creating a new instance of the activity. The activity can be instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances (but only if the activity at the top of the back stack is not an existing instance of the activity).For example, suppose a task's back stack consists of root activity A with activities B, C, and D on top (the stack is A-B-C-D; D is on top). An intent arrives for an activity of type D. If D has the default "standard" launch mode, a new instance of the class is launched and the stack becomes A-B-C-D-D. However, if D's launch mode is "singleTop", the existing instance of D receives the intent through onNewIntent(), because it's at the top of the stack—the stack remains A-B-C-D. However, if an intent arrives for an activity of type B, then a new instance of B is added to the stack, even if its launch mode is "singleTop".
簡(jiǎn)單來說就是: 處于堆棧的棧頂,并且不會(huì)重新實(shí)例化新的對(duì)象
- "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.
不會(huì)重新實(shí)例化對(duì)象
- "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",區(qū)別在于系統(tǒng)不會(huì)啟動(dòng)任何的activities放到這個(gè)任務(wù)堆棧中去處理這個(gè)實(shí)例.并且在這個(gè)被設(shè)置成"singleInstance"的Activity任務(wù)棧中只有他一個(gè).由它啟動(dòng)的Activity都會(huì)被push到一個(gè)新的堆棧中.