Among them, Oncreate corresponds to Ondestory, OnStart corresponds to OnStop, and OnResume corresponds to OnPause.
upon creationThe : statement is called on create to create a new instance to complete some initialization operations.
onStart：activityGet ready for the show but you can’t interact.
onResume: Activity can receive focus and you can interact in this state.
on pause: activity that runsin another placeThe activity is called upon return to the front desk.
onStop: If the activity’s dispatch terminates the activity, it will be called.
jumpReally: do Onpause first, then do B Oncreate and OnStart. If B is not transparent, then A’s OnStop method will be executed. If it is transparent, for example, the message box will not be executed. Then take B’s Oneresume.
saving information: If the memory is too tense, it will go straightOndetory does not necessarily accept OnStop, so save state information should be handled in OnPause, not OnStop.
The Internet has interview questions to saywhen we leaveOncreate is not accepting to startThe essence of this, if it is notOncreate calls the end method (this is not useless. In some special cases, we need this action to complete some initialization operations, but it does not need to be displayed to the front desk.).
onRestart: After activity is Onstop and not Ondestroy, when starting this activity again call OnRestart
onSaveInstanceStateTranslationA: This is not a life cycle because it cannot be named. Press the power button, turn off the screen, rotate the screen, pressHome key, go to another activity, do not fall into the art of movement until the end. This usually happens when it stops or stops. For example, if the user actively destroys it, or calls the partition actively, or the back button will not be called, because in this case, the user behavior sets the state for not saving the activity.
userOnsaveInstanceState () is only suitable for saving some temporary states, and OnPause () is suitable for persistent data saving.
onRestart : When the activity is in the Onstop state, it needs to be displayed again.
onRestoreInstanceStateA: It does not belong to the life cycle of the Activity, and does not artificially call the finish line next time. But it is not associated with OnsaveInstanceState. It can be called once if it can be killed, but OnRestoreInstanceStancate must be specified by Dinish
on the new intention：The Activity has four modes of play: Standard, Single、Singletop, Singletask. Only in standard mode it will not be called.
Since the starting mode is also related to the life cycle, let’s briefly talk about these starting modes:
The default mode of operation if you start each time (eg start and run again on return).
Focus on this“top”, which means the top of the stack. This is when it should be created. If there is this instance at the top of the stack, it will be reused. Currently the top of the stack will be called. But there is one of the stacks and then one will be generated. It will be created now. It is no longer called Onnewintent, but called Oncreate. Therefore, this mode focuses on the top of the stack. entity but if command is -b->a->b, it will return back to B. (If it is at the top of the stack, it will not be created again. If not, it will be the same as the standard mode)
single task ：
The focus is on “one”. Unlike Singletop and Singletask, if there is this instance on the stack, this instance will be used at the top of the stack (of course, Oncreate is not acceptable) Questions, but it should be noted that because it is pushed to the top of the stack, other iterators will be removed before this instance is removed. Only the examples on the stack will go into the build. For example, A is Singletask mode, B and C are Standard mode. In order of reuse, the next order is B->A->C->A directly to B.
1 copy ：
focus on“Example”, that is – this is the only case. If there is no example, this model will create a new stack and only this example is stored in the stack. Every Activity it runs on this instance without creating a new instance. In this process, there is always a SingleInstance mode. Only one instance, Singletask is not guaranteed. For example, a is standard mode, B is one-way ordering: A->B->A->B, this is the case in this process: insert B into the first A, B is not yet because there is no dimension. The instance creates a new stack of tasks, creates instance B, and then starts B again. Currently the second A will be at the top of the first stack (not the same stack as B, B to enjoy the stack)) Running b found that there are already instances, but no new instances are generated. When we click on the button on the back, we will bring this back to the desktop again.
The above examples do not provide source code and do not run screen shots which have been tested by our readers.