Startup mode of [Android] activity
Create two activities and two layout files. There are two buttons in the layout to open the first and the second
When the first interface is opened, the process will create a task stack with only one activity in the stack
Click the second interface, and activity2 will be added to the task stack
Click the second interface again and add activity2 to the task stack again
When you click return, the last one will pop up first and then one by one. This is the standard mode in the standard case
In some special cases, in order to avoid bad user experience, if this activity is found at the top of the task stack, it will not be created again for a long time. This mode is the startup mode of singletop, single top
In the manifest file, under the activity node
Set startup mode Android: launchmode = "singletop"
Application scenario: bookmarking interface and SMS interface of browser
Function: prevent the same interface from being opened repeatedly
The singletask mode, a single task stack, is tested by clicking the return key, which is different from the singletop mode
To start an activity, check the task stack. If it already exists, clear all other interfaces on the activity and reuse the interface
Application scenario: for browser application, look up the list file and see that broweractivity is in this mode. This activity is cumbersome because it is the core of WebKit browser written in C. when multiple tabs are opened, it is actually only an activity instance, which saves resources.
Singleinstance mode, single instance. After the interface is started and the task stack is opened, click this interface to create a separate task stack, which only stores this activity instance. If this activity is opened, the activity task stack will be put in front. This mode is very extreme. There will only be one instance in the whole operating system.
Application scenario: telephone interface, fast word selection of Youdao dictionary