Preliminary cognition of 1--activity life cycle of documentary film

Source: Internet
Author: User

The first time to write a blog, just to record my study of a process, write bad hope to see people do not spray, thank you

Activity life Cycle is one of the most basic points of learning Android, or is a key point, not only to remember, but also to understand, and not to say more into the topic:

The activity life cycle is divided into seven: OnCreate (), OnStart (), Onresume (), Onrause (), Onrestart (), OnStop (), OnDestroy (), each of which is a cycle, The transactions or things that are handled by each cycle are inconsistent or similar;

Anthracene, leave a life cycle diagram, perhaps more directly to see:


OnCreate (): This method is believed to be known to everyone, because when creating a new activity interface, it will be created first, this method must be rewritten, it is called when the activity is first created, what you need to do is, in this method, Perform some initialization operations, such as loading layouts, event bindings, and so on;

OnStart (): is a process by which the invisible becomes visible, in which the resources can be loaded;

Onresume (): This is the method to be called when it is ready to interact with the user, at which point the activity must be at the top of the stack and is active;

Onrause (): This method is called when the system is ready to start or resume another activity, which is commonly said to be a pause action, in which we can release some of the CPU-consuming resources and save some key data.

Onrestart (): This method is called before the activity is changed from the stop state to the running state, that is, the activity is restarted;

OnStop (): This method is called when the activity is completely invisible;

OnDestroy (): This method is called before the activity is destroyed, and then the active state becomes the destruction State;

The above is my simple understanding of the activity life cycle, there is nothing wrong where I hope you can point out, thank you;

How are these life cycles invoked when an activity is started, as follows:

Let's start by creating two windows, A and B, respectively:

When a new window a starts, it executes the call OnCreate, OnStart, Onresume three methods;

Click the Jump button to jump to the new page cycle changes as follows:

At this time, window A will execute OnPause first, then window B will execute OnCreate, OnStart, Onresume, onStop;



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.