Android Activity life Cycle

Source: Internet
Author: User

The activity life cycle graph extracted from the Android API documentation is as follows:

There are four states of activity

A, active activity in the screen foreground, get the focus can interact with the user, only one activity is active at the same time

B, suspend state activity visible but loses focus (obscured by other activity or under transparent Activiy)

C, stop state activity is completely obscured by another activity, but retains user state information D, inactive activity has not been started or has been manually terminated or is being reclaimed by the system due to insufficient memory

Important methods in the activity life cycle

A, OnCreate loading layout files, binding various types of monitoring events

B, OnStart interface visible but failed to get focus, cannot interact with user

C, Onrestart when the activity executes the OnStop method, then the boot time will be called

D, Onresume interface visible and can get the focus, can interact with the user

E, OnPause interface loses focus, but visual

F, onstop when activity is not visible at all

G, OnDestroy manual call to finish or low memory system recovery


For example, the activity of each method switch, a new a,b,c three activity, where B is set to transparent

A, start the main page a,oncreate (a)-OnStart (a)-Onresume (a)

B. Open transparent B,onpause (A)-oncreate (b)-OnStart (b)-Onresume (b)

C, click the Back button to return to the page A,onpause (b)-Onresume (A)-OnStop (b)-OnDestroy (b)

D. Open Full Screen page c,onpause (a)-onCreate (c)-OnStart (c)-Onresume (c)-OnStop (a)

E, click the Back button again, OnPause (c)-Onrestart (a)-OnStart (a)-Onresume (a)-onStop (c)-OnDestroy (c)

F, then click Back OnPause (a)-onStop (a)-OnDestroy (a)

Android Activity 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.