Android Startup Mode and Android Startup Mode
In simple terms, the startup mode is the policy when the Activity is started. In AndroidManifest. xml, the android: launchMode attribute of the <Activity> tag is set;
There are four startup modes: standard, singleTop, singleTask, and singleInstance;
Activity Startup Mode settings:
<Activity android: name = ". MainActivity" android: launchMode = "standard"/>
Four startup modes of Activity:
1. standard
In startup mode, the Activity is created every time the Activity is activated and placed in the task stack.
2. singleTop
If an instance of the Activity exists at the top of the stack of the task, the instance is reused. Otherwise, a new instance is created and placed on the top of the stack (even if the Activity instance already exists in the stack, instances will be created as long as they are not at the top of the stack ).
3. singleTask
If an instance of the Activity already exists in the stack, the instance will be reused (onNewIntent () of the instance will be called ()). When it is reused, the instance will be sent back to the top of the stack, so the instance on it will be removed from the stack. If this instance does not exist in the stack, a new instance is created and put into the stack.
4. singleInstance
Create the Activity instance in a new stack and share the Activity instance in the stack with multiple applications. Once an instance of a modified Activity exists in a stack, any application that activates or changes the Activity will reuse the instance in the stack. The effect is that multiple applications share one application, no matter who activates the Activity, it will enter the same application.