Open directly
OnCreate the method to invoke when the activity is to open (starting)
OnStart the method that is called when the UI of the current activity is visible to the user
Onresume Current activity starts responding to user interaction (the activity gets to the focus call method)
Press the back key
OnPause the current activity loses focus call method (becomes background)
OnStop The current Activity interface The user cannot see the calling method
OnDestroy perform some cleanup operations when the activity is being destroyed
minimizing applications
OnPause
OnStop
Activity life cycle can be divided into 3 types according to the range
1. Full life cycle oncreate create OnStart user visible Onresume Get focus onpasue lose focus OnStop user is not visible ondestory destroyed.
2. Visual life cycle interface always visible to users
OnStart () Visible onresume get focus onpasue lose focus OnStop () User not visible
Onrestart ()
3. Foreground life cycle Onresume-onpause
Screen switching is actually the process of activity destruction and reconstruction.
Workaround
1. Fixed screen orientation
<activity
android:screenorientation= "Portrait"//Vertical screen
android:screenorientation= "Landscape"//Horizontal screen
/>
2. Ignore changes in the screen
<activity
Android:configchange= "Orientation|keyboardhidden|screensize"
/>
Activity life cycle