In android, there are four kinds of activity startup mode, are: standard, singleTop, and singleTask singleInstance, wherein singleTop and similar standard, and the like singleTask singleInstance, used as follows:
(1).standard和singleTop
Loading both modes, the same task can be multiple instances of an activity, the activity stack and may be located anywhere .
First example:
Suppose target task activity stack is: A-> B-> C-> D (bottom of the stack -> stack)
Call startActivity (D) in the program
If D is the standard mode, the activity stack becomes:
A-> B-> C-> D-> D, that is, re-create an instance of D
If D is singleTop mode, the activity stack becomes :
A-> B-> C-> D, D does not create instance, that if the target task D activity stack stack, will not create a new instance, but the call onNewIntent D () method, and vice versa If D is not in the target task stack stack of activity, it will re-create an instance of D
(2). singleTask和singleInstance
In both loading mode, the same task can only exist in an instance of activity, if by startActivity () to start, then call onNewIntent () method, rather than creating a new instance. In these two modes, activity instances are located in the bottom of the stack activity stack.
Difference between these two modes of load:
Suppose an Activity Example A, the following two loading modes:
singleTask:
If the call startActivity A (B) B Example start, then A and B are located in the same task.
singleInstance:
If A calls startActivity (B) B start example, the system will automatically add a property to the intent FLAG_ACTIVITY_NEW_TASK, the B instance put to a new task, that is task A instances where there can be only A themselves, not There are other examples
Reproduced in: https: //www.cnblogs.com/wangzehuaw/p/4977649.html