Activity of four Android components: androidactivity

Source: Internet
Author: User

Activity of four Android components: androidactivity

1. activity

(1) an Activity is usually a separate screen (window). In short, activity is an interactive interface. Generally, an application must be composed of one or more activities.

(2) Activities communicate with each other through Intent.

(3) Every Activity in the android Application must be declared in the AndroidManifest. xml configuration file. Otherwise, the system will not recognize or execute the Activity.

(4) Activity Lifecycle

The startup sequence of an Activity:

OnCreate () --> onStart () --> onResume ()

When another Activity is started:

The first Activity onPause () --> The second Activity onCreate () --> onStart () --> onResume ()

--> The first Activity onStop ()

When the first Activity is returned:

The second Activity onPause () --> the first Activity onRestart () --> onStart () --> onResume ()

--> The second Activity onStop () --> onDestroy ()

Activity Status

Generally, Activity has the following four States:

Active: when an Activity is on the top of the stack, it is visible, focused, and user input acceptable. Android tries to maintain its Activity status as much as possible, killing other activities to ensure that the current Activity has enough resources to use. When another Activity is activated, it will be paused.

Pause: in many cases, your Activity is visible but has no focus. In other words, it is paused. The possible cause is that a transparent or non-full screen Activity is activated.

When paused, an Activity is regarded as an Activity, but user input is not acceptable. In special cases, Android will kill a paused Activity to provide sufficient resources for the Activity. When an Activity changes to completely hidden, it changes to stopped.

Stop: when an Activity is not visible, it is "STOPPED. This Activity will still store all its status and member information in the memory. However, when memory is needed elsewhere, it is most likely to be released. When an Activity is stopped, a very important step is to save the data and the current UI status. Once an Activity exits or is disabled, it will become available.

Waiting for use: after an Activity is killed and put in front, it is waiting for use. To be used, Acitivity is removed from the Activity stack and needs to be restarted before display and availability.

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.