Android life cycle

Source: Internet
Author: User

Method Description can it be killed later? Next Method
OnCreate () Called when the activity is created for the first time. Here you should do all the usual static setup work-creating a view, binding the list data, and so on. This method passes in a bundle object that contains the previous state of the activity (if it was previously captured, see saving Activity State later).

The next callback method is always OnStart ().

Whether OnStart ()
Onrestart () Called before the activity is stopped and then started again.

The next callback method is always OnStart ()

Whether OnStart ()
OnStart () Called before the activity is to be displayed to the user.

If the activity enters the foreground, the next callback method is Onresume (), or the next callback method is OnStop () if it goes into a hidden state.

Whether Onresume () or onStop ()
Onresume () Called before the activity starts interacting with the user. The activity is at the top of the activity stack, where the user can enter it.

The next callback method is always OnPause ().

Whether OnPause ()
OnPause () Called when the system is ready to start another activity that is recovering. This method is commonly used to commit unsaved changes to permanent data, stop animation playback, and other tasks that may consume CPU, and so on. It should complete the work very quickly, because the next activity will not be resumed until the method returns.

If the activity returns to the foreground, the next callback method is Onresume () and if the user is not visible, the next one is OnStop ()

OK Onresume () or onStop ()
OnStop () Called when activity is no longer visible to the user. The reason may be that it is about to be destroyed, or that other activity (existing or new) is resumed and will overwrite the activity.

If the activity also comes back to interact with the user, the next callback method is Onrestart (); If the activity is about to disappear, the next callback method is OnDestroy ()

OK Onrestart () or OnDestroy ()
OnDestroy () Called before the activity is destroyed. This is the last call the activity received. It may be because the activity has finished working (some people call finish here), or it may be because the system temporarily destroys the activity's instance in order to make room for it. You can use the Isfinishing () method to differentiate between the two cases. OK No

Android life cycle

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.