My android learning experience 2 and android learning experience 2
Lifecycle of an activity in android
There are seven major cycles
OnCreat ();
OnStart ();
OnResume ();
OnPause ();
OnStop ();
OnRestart ();
OnDestory ();
OnCreat () is called when the activity is run for the first time, and onStart () is called on the interface. onResume () is called when the focus is obtained.
When the second activity is called, The onPause () of the first activity is called. When the second activity completely overwrites the first acticity
The onStop () of the first activity is called when the first activity is not reached. If the second activity does not completely overwrite the first activity, the first activity is not called.
OnStop (). The onRestart () method is called after the back key is fully overwritten. When the finish () method is called or the system automatically exits, onDestory () is called ()
If you have any questions, please leave a message in the comment area. Thank you.