Activity startup mode

Activity startup mode

Experimental environment: Xiaomi MAX2, Android 7.1.1

1.standard (standard mode)
2.singleTop (stack top multiplexing mode)
3.singleTask (in-stack multiplexing mode)
4.singleInstance (single instance mode)
5. The case of characteristics

1.standard (standard mode)
In any case, a new Activity instance will be created and placed in the task stack.

2.singleTop (stack top multiplexing mode)
If there is no instance in the current task stack, then create a new instance and put it on the top of the stack.
If the instance in the current task stack is already at the top of the stack, a new instance will not be created, but the instance will be reused (the onNewInstance method is called).
If there is this instance in the current task stack, but it is not on the top of the stack, then create a new instance and put it on the top of the stack.

3.singleTask (in-stack multiplexing mode)
If the required task stack is not the current task stack, a new task stack will be created, and then a new instance will be created and placed in the new task stack.
If the required task stack is the current task stack, and no instance exists in the current task stack, a new instance will be created and placed in the new task stack.
If the required task stack is the current task stack, and there is an instance in the current task stack, and the instance is at the top of the stack, reuse the instance (call the onNewInstance method).
If the required task stack is the current task stack, and there is an instance in the current task stack, but the instance is not at the top of the stack, then reuse the instance (call the onNewInstance method), but it will force all Activity instances before the instance to exit. stack.

4.singleInstance (singleton mode)
has all the properties of the singleTask mode, but the instance can only exist alone in a new task stack and is unique.

5. Special cases
Suppose there is a task stack S1, which has two Activity instances of AB, and a task stack S2, which has two Activity instances of CD, but the CD startup mode is singleTask (at this time, S2 is the background task stack).
If D is to be started at this time, the two task stacks will synthesize a new task stack ABCD.
If C is to be started at this time, the two task stacks will be combined into a new task stack ABC, and D has been forced to pop out of the stack at this time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843141&siteId=291194637