Activity in Android is used to display the user interface, which is the interface that the user sees and acts on.
The activity component in the Androidmanifest file that contains the filter below is the default startup class for the program, which is automatically called when the program starts (the first page that is displayed when the program starts).
< Intent-filter > < android:name= "Android.intent.action.MAIN"/> < android:name= "Android.intent.category.LAUNCHER"/></ Intent-filter >
Activity life cycle Diagram
Here OnCreate () (Create), OnStart () (start), Onresume () (recovery) is not to say, all for run to prepare.
OnPause () state and OnPause ()->onresume () status
When activity is obscured (there is another transparent activity or toast, alertdialog, etc.), such as jumping from mainactivity to secondactivity, Then the mainactivity is in the OnPause () state, and when the return key is returned from Secondactivity to Mainactivity, the mainactivity State is OnPause ()->onresume ().
OnStop () state and Onstop->onstart () status and OnStop ()->onrestart->onstart () status
When the actvity is completely invisible, for example, when mainactivity presses the home key, Mainactivity is in the OnStop () state at this time. Return to Mainactivity again by OnStop ()->onstart ().
And when mainactivity jumps to secondactivity and jumps to thridactivity, Mainactivity is completely blocked in the OnStop () state, Press the back key back to Secondactivity when Mainactivity is in the Onrestart () state and press the back key again to return to Mainactivity by Onrestart ()->onstart ().
OnDestroy () status
Die
State on the left
When other applications need to use memory and the program is killed when there is not enough memory, it needs to be recreated
The activity life cycle of Android four components