The life cycle of an Android application is more clear than the explanation.
Create a demo with the following code:
public class Mainactivity extends Activity {private static final String TAG = "Android_life"; @Overrideprotected void Oncre Ate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); LOG.I (TAG, "onctreate ()"); Setcontentview (R.layout.activity_main);} protected void OnStart () {Super.onstart (); LOG.I (TAG, "OnStart ()");} protected void Onresume () {super.onresume (); LOG.I (TAG, "Onresume ()");} protected void OnPause () {super.onpause (); LOG.I (TAG, "OnPause ()");} protected void OnDestroy () {Super.ondestroy (); LOG.I (TAG, "OnDestroy ()");}
The effect of running the program is as follows:
1) The first time you run the program, you can find the log information as follows: "Note time"
03-10 20:38:11.531:i/android_life (4635): Onctreate ()
03-10 20:38:11.641:i/android_life (4635): OnStart ()
03-10 20:38:11.641:i/android_life (4635): Onresume ()
2) Turn off the phone screen
03-10 20:38:11.531:i/android_life (4635): Onctreate ()
03-10 20:38:11.641:i/android_life (4635): OnStart ()
03-10 20:38:11.641:i/android_life (4635): Onresume ()
03-10 20:38:29.451:i/android_life (4635): OnPause ()
3) Activate the phone screen
03-10 20:38:11.531:i/android_life (4635): Onctreate ()
03-10 20:38:11.641:i/android_life (4635): OnStart ()
03-10 20:38:11.641:i/android_life (4635): Onresume ()
03-10 20:38:29.451:i/android_life (4635): OnPause ()
03-10 20:53:51.631:i/android_life (4635): OnStart ()
03-10 20:53:51.731:i/android_life (4635): Onresume ()
4) exit the application and you can see the log
03-10 20:57:51.161:i/android_life (5779): OnDestroy ()
Android life cycle (iii)