1, an application is generally composed of multiple activity, task stack, record and store user-opened activity.
2, when an application is opened, the system will assign him to a task stack, when all the activity in the task stack exits, the task stack is emptied. The ID in the task stack is an integer data type (self-growing).
3, in the Android operating system there will be multiple task stacks, an application corresponding to a task stack.
4. By default, by shutting down an application, the system will empty the application. But the process of the application is also preserved
Why should I introduce the concept of a task stack?
In order to record what activity the user has turned on, and to record the order in which the activity was opened, Google introduced the task stack concept in order to have a better user experience.
You can specify the mode of the task stack in the activity's startup mode:
To configure the activity in Androidmanifest.xml:
<activity android:name= ". Mainactivity "android:launchmode=" singleinstance ">
Four modes of startup:
1, standard default boot mode, each time startactivity is to create a new activity instance
2, Singletop single top mode, if the activity to be opened already exists at the top of the task stack, it will not create a new instance, but use the top instance directly
3, Singletask a single task stack, if there is already an instance of the activity in the stack, reusing the instance will invoke the instance's Onnewintent (). When reused, the instance is returned to the top of the stack, so the instances above it will be removed from the stack. If the instance does not exist, a new instance is created into the stack. Note: Singletask mode activity Whether it is at the top or bottom of the stack, running the activity again, will destory off its activity to ensure that the entire stack only one, remember "This is beyond doubt."
4, SingleInstance Singleton Single instance mode, the entire mobile phone operating system only one instance exists, the activity is always at the top of the stack (because he is the only activity in the task), so always able to properly handle the behavior
(GO) Android Learning notes---Android task stack and startup mode