After knowing the basic activity life cycle, we are able to do a good job of doing business on an activity. But this is not enough, because Android through the task stack to save the entire app activity, reasonable scheduling task stack to provide a good user experience. And the structure of the stack, I believe we all know-advanced after the linear table, the new activity will be located on the stack top of the task stack, in the active state, the other activity is not active, but still remain in the task stack, in the state of being stopped (that is, OnStop is triggered, But Ondestory is not triggered).
In general, the return key and the call to finish method will remove the activity at the top, and then let the subsequent activities resume, but that is generally the case. The properties under the Androidmainfest.xml file Android:launchmode or intent flag can break this state.
The following will first introduce the Androidmainifest startup mode
- Standard
- Singletop
- Singletask
- SingleInstance
1. Standard
The default startup mode, if you do not specify the activity's startup mode, use this mode to start the activity, in which case a new instance is created each time the boot is started. Once created, the activity will be covered by the original activity. The state of the stack in this startup mode is shown:
2.singleTop
If you specify start activity as Singletop mode, the start will determine whether the current stack top is the activity to start, if not create a new activity instead of directly referencing the activity, if not create a new activity, This pattern usually applies to the interface that is displayed after receiving the message.
Android Activity Task Stack