Activity life cycle

Source: Internet
Author: User

There are four states of Activity

  1. Active or running state, at which time the activity runs at the front of the screen
  2. Paused, at which time the activity loses focus but remains visible to the user (e.g., this activity obscures a transparent or non-full-screen activity)
  3. Stop state, when activity is completely covered or gone
  4. The activity is cleared out of memory by the system at the end of the state.

The life cycle of an activity can be differentiated into a complete life cycle, a visible life cycle, and a foreground life cycle based on different criteria.

1. The process of initially calling the OnCreate () method from activity to the final call to the OnDestroy () method is called the complete life cycle. The activity will set all global states in the OnCreate () method, releasing all the resources it holds in the OnDestroy () method.

2, from the activity Call OnStart () method to start, to the corresponding OnStop () method So far this process is called the visible life cycle. At this time, the user can see the activity on the screen, although not necessarily in the foreground, and may not necessarily interact with it. Between these two methods, the user can maintain the resources that the activity needs to display. Because the corresponding method is called whenever the activity is displayed or hidden, the OnStart () method and the OnStop () method can be called multiple times throughout the life cycle.

3, starting from the activity Call Onresume () method, to call the corresponding OnPause () method, this process is called the foreground life cycle. At this time, the current activity is in front of all other activity and can be used to interact with the data.

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.