Should know: Android activity refined out OnCreate, OnStart, Onresume, OnPause, OnStop, Ondesdroy 6 ways to let the application to overload, which asked why? Click to view Android activity why refine the OnCreate, OnStart, Onresume?
This shows only when the 6 functions are called and the order in which they are called:
An activity starts normal Startup: OnCreate ()->onstart ()->onresume ();
An activity starts normal exit: OnPause ()->onstop ()->ondestory ()
One activity starts another activity:onpause ()->onstop (), and then returns: Onrestart ()->onstart ()->onresume ()
An activity press back to exit: OnPause ()->onstop ()->ondestory (), then enter: OnCreate ()->onstart ()->onresume ();
An activity press home to exit: OnPause ()->onstop (), then enter: Onrestart ()->onstart ()->onresume ();
Sometimes you may have questions? : If my program is
public class Mainactivity extends Activity
{
public void Oncreat () {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);
}
}
OnStart () and Onresume () are not executed, how can the simulator be executed?
In fact, this activity inherits the parent activity and invokes the activity of the parent class, if you want to make the program perfect: It is best to reload OnStart () and Onresume ().
Android Activity Lifecycle-don't just use the OnCreate method