Google Developer Documentation
Http://developer.android.com/reference/android/app/Activity.html
Each page of the app is an activity that is stored in an activity stack, and each time it enters an application or an interface of an application, the activity is pushed to the top of the activity stack. When exiting or returning, the activity on the top of the stack pops up, and the activity goes to the top of the stack.
Four states in the activity life cycle
-Running:activity is located at the front desk (top of the stack) and is visible to the user, gaining focus
-Paused: Other activity in the foreground, currently active in the stack, but not at the top of the stack, can not get the focus
-Stopped: Current activity is not visible, loses focus, waits for system to end
-Destroy:activity end or end of Dalvik process
Life cycle diagram of activity
The activity's life cycle is clearly visible through this diagram.
As you can see, there are 7 methods that will be recalled by the system during the activity's life cycle:
-OnCreate (Bundle savedstatus): When you create an activity
-OnStart (): When you start activity
-Onrestart (): When you restart activity
-Onresume (): This method must be called after the OnStart method when the activity is resumed
-OnPause (): When activity is paused
-OnStop (): When activity is stopped
-OnDestroy (): When the activity is destroyed
In development, the most basic is to overwrite the OnCreate method, for the control initialization, in addition, OnPause can be used in the game to save the phone when the state, Onresume used to hang up the phone after the recovery state; Onresume method can also be used to refresh data on return, etc.
Public class Activity extends applicationcontext { protected void onCreate(Bundle savedinstancestate);protected void OnStart();protected void Onrestart();protected void Onresume();protected void OnPause();protected void OnStop();protected void OnDestroy(); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The life cycle of "Android Essentials" activity