In Android, there are 4 activation modes for the activity: standard, Singletop, Singletask and SingleInstance, where standard and singletop are similar, Singletask and singleinstance are similar, use the following:
(1). Standard and Singletop
In both load modes, multiple instances of an activity can exist in the same task, and can be anywhere in the activity stack.
Let me give you an example:
Assume that the activity stack for the target task is: a->b->c->d (stack bottom, top of stack)
Calling StartActivity (D) in the program
If D is standard mode, the activity stack changes to:
A->b->c->d->d, which will re-create a D instance
if D is singletop mode, the activity Stack becomes :
A->b->c->d, the D instance is not created, that is, if D is at the top of the activity stack of the target task, it does not create a new instance, but rather calls the Onnewintent () method of D, and vice versa if D is not in the target task The top of the activity stack, a D instance is recreated
(2). Singletask and SingleInstance
In both load modes, only one instance of the activity exists in the same task, and if started by StartActivity (), the Onnewintent () method is called instead of creating a new instance. In both of these modes, activity instances are located at the bottom of the activity stack.
The difference between the two load modes:
Suppose an activity instance a uses the following two loading modes:
Singletask:
If a calls StartActivity (b) to start the B instance, a and B are in the same task.
SingleInstance:
If a calls StartActivity (b) to start a B instance, the system automatically adds a property flag_activity_new_task to intent, puts the B instance into a new task, which means that the a instance is in a task that has only a self, No other instances exist
Four modes of loading for activity