Four startup modes of Android_06_Activity
Four startup modes of Activity
> Each application has an Activity Task Stack that stores started activities.
> The Activity startup mode is used to modify the arrangement of the task stack.
In the configuration file, you can set the Activity startup mode, for example:
Note: The launchMode attribute is used to modify the startup mode.
The four startup modes have the following features:
1> standard Startup Mode
The standard Startup Mode follows the features of the stack and is advanced
2> singleTop single top mode
If the activity to be enabled exists at the top of the stack of the task stack, the existing activity is reused instead of re-creating the activity.
Ensure that if the stack top exists, it will not be created again; if the activity is not on the top of the stack, it will still be created again even though it has been previously created.
Application Scenario: browser bookmarks
3> singeTask: a single job stack can only have one instance in the current job stack.
When activity is enabled, check whether an instance already exists in the task stack. If an instance exists, reuse the existing activity,
In addition, all other activities on this activity are cleared and reused. Ensure that only one instance exists in the entire task stack.
Application Scenario: browser activity
If the creation of an activity requires a large amount of system resources (cpu, memory), the activity is generally configured as the start mode of singletask.
Note: The range of the preceding three modes is that only one task stack is created in each application,
In the fourth mode, singleInstance only has one activity instance in the entire operating system.
4> the singleInstance startup mode is very special. The activity runs in its own job stack, and only one instance exists in the job stack.
If you want to create multiple activities, they will not be created again, but will be moved from the background to the foreground. If you click back to destroy the activity
It will not exist! This new Task Stack containing activity will not exist!
If you want to ensure that only one instance exists for an activity in the entire mobile phone operating system, use singleInstance
Application Scenario: Call Interface