The activity life cycle of Android four components

Source: Internet
Author: User

Activity in Android is used to display the user interface, which is the interface that the user sees and acts on.

The activity component in the Androidmanifest file that contains the filter below is the default startup class for the program, which is automatically called when the program starts (the first page that is displayed when the program starts).

< Intent-filter >     <  android:name= "Android.intent.action.MAIN"/>     <   android:name= "Android.intent.category.LAUNCHER"/></ Intent-filter >


Activity life cycle Diagram

Here OnCreate () (Create), OnStart () (start), Onresume () (recovery) is not to say, all for run to prepare.

OnPause () state and OnPause ()->onresume () status
When activity is obscured (there is another transparent activity or toast, alertdialog, etc.), such as jumping from mainactivity to secondactivity, Then the mainactivity is in the OnPause () state, and when the return key is returned from Secondactivity to Mainactivity, the mainactivity State is OnPause ()->onresume ().

OnStop () state and Onstop->onstart () status and OnStop ()->onrestart->onstart () status

When the actvity is completely invisible, for example, when mainactivity presses the home key, Mainactivity is in the OnStop () state at this time. Return to Mainactivity again by OnStop ()->onstart ().

And when mainactivity jumps to secondactivity and jumps to thridactivity, Mainactivity is completely blocked in the OnStop () state, Press the back key back to Secondactivity when Mainactivity is in the Onrestart () state and press the back key again to return to Mainactivity by Onrestart ()->onstart ().

OnDestroy () status

Die

State on the left

When other applications need to use memory and the program is killed when there is not enough memory, it needs to be recreated

The activity life cycle of Android four components

Related Article

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.