Android Activity Lifecycle-don't just use the OnCreate method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.