First, what is activity?
Simply put: Activity is an interactive interface that fills the window or hovers over other windows. In an application that is typically composed of multiple activity, a master activity is specified in the Manifest.xml, as set
<actionandroid:name= "Android.intent.action.MAIN"/>
When the program first runs, the user will see the activity, which can be manipulated by initiating other activity. This current activity will stop when other activity is started, and the new activity will be pushed into the stack and the user focus will be taken while the activity is being manipulated. All know that the stack is advanced after the principle, then when the user presses the back key, the current activity is destroyed, the previous activity resumed.
Second, activity life cycle
See:
Three, start mode
Android defines four loading modes for us: Standard, Singletop, Singletask, and SingleInstance.
In standard load mode, when a task request loads an activity, the task instantiates the activity directly and puts it on top of the stack, regardless of whether there is an instance of the activity in the previous stack.
When activity is set to the load mode of Singletop, when a task request loads an activity, if the stack top of the task's corresponding stack is an activity instance, then it is not recreated, but instead calls Onnewintent. If an instance of activity in the stack for that task exists, but not at the top, then the activity is still recreated. Simply put, the focus activity (current activity) can no longer activate an instance of itself. Activity in Singletop mode can be instantiated multiple times, but it is not possible to overlap multiple instances of the same activity.
Singletask load mode, when a task request loads an activity, it is not recreated if there is an instance of activity in the corresponding stack for that task. If it has already been instantiated, the activity instance on the task will be destroyed and called Onnewintent. In a word, activity in Singletask mode has only one instance in its own task and does not allow other activity to override itself on startup
In singleinstance this mode, when a task request loads an activity, if there is an instance of activity in the stack of all the tasks, it is not recreated. If there is not an instance of activity in the stack of all the tasks, then the instance of the activity is created and a new task is exclusive, and the other activity cannot exist in the task.
Android series six (activity startup mode and lifecycle)