The life cycle of Android development

Source: Internet
Author: User

the life cycle of Android development
One: Life cycle of activity:
  • These days, we have learned about the life cycle of Android activity and have a general understanding of the life cycle.
  • the life cycle of an activity is the activity from the build to the run, to the other interface when it is paused, until the other interface to stop the generation, or re-enter the interface rewrite to start, until the last activity was destroyed a series of processes; Activity is managed by the activity stack, and when it comes to a new activity, the activity is added to the top of the activity stack, and the activity is at the bottom of the activity. There are four states in the general sense of acitivity:

    1. When the activity is at the top of the stack, it is in the front of the screen at this time and is in a running state ;

    2. When the activity loses focus but remains on the visible (such as the top of the activity is transparent or the top of the stack activity is not covered with the entire phone screen), at this time in a paused state ;

    3. When activity is completely obscured by other activity, the activity is not visible to the user at this time and is in a stopped state ;

    4. When the activity is destroyed due to human or system reasons (such as low memory, etc.), it is in the destruction state at this time;

  • (a) When the activity begins, it is called First: Oncreat () >>>onstart () >>>onresume (), at which point (a) the activity interface enters our sight ; activity begins to run;
  • when jumping to another (b) activity, that is, entering another interface,(a) the activity invokes the OnPause () function, enters the pause phase, and then (b) the activity begins as if (A) activity starts, Call: Oncreat () >>>onstart () >>>onresume (), when (B) activity enters our line of sight, when it starts to run, (A) the activity invokes the OnStop () function ; in a stopped state;
  • When we press the back menu to return, (B) the activity invokes the OnPause () function, enters the paused state, and (A) the activity invokes: The Onrestart () >onstart () >onresume () function then (a) the activity interface enters our interface, and (B) activity calls OnStop () >>ondestroy () function, at which time (B) the activity is destroyed;
  • and when we call the button that we define on the interface to return (a) activity, (B) The activity also enters the pause first, that is, the OnPause () function is called, but (A) the activity is called: O Ncreat () >>>onstart () >>>onresume (), in other words, regenerates a (a) activity instead of returning to the previously created (a) activity And then (B) the activity calls OnStop () to suspend, not destroy;
  • So the return button on the menu is different from the one defined on the interface.
  • when (a) the activity is turned over to a (c) activity that is displayed as a speech-frame mode , the same (a) activity invokes the OnPause () function, enters the pause phase, and (c) the activity first invokes the Oncreat () >>>onstart () >>>onresume (), at which point (a) the interface of the activity enters our sight; (a) activity does not stop, that is, there is no method to call OnStop , and (A) the activity calls OnStop () to cease only when we log in to other activity from (C) activity;
  • when you enter (c) activity and press the Back button , (c) the activity calls the OnPause () method to pause, and then the last activity here is (A) the activity invokes the Onresume () function (a) The activity interface appears in front of us, and (C) the activity invokes the Onstop>>ondestroy () function for destruction;Click (A) the activity interface as well .
  • In addition: When the activity calls the OnPause () into the pause phase, if the memory is low, the program will be killed, that is, destroyed;
two. Several functions that make up the life cycle:

The life cycle of Android development

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.