Android four components of activity introduction

Source: Internet
Author: User

1. Activity

(1) An activity is usually a separate screen (window), simply speaking, activity is an interactive interface, and a general application consists of one or more activity.

(2) Communication between activity through intent.

(3) Every activity in an Android app must be declared in the Androidmanifest.xml configuration file, or the activity will not be recognized or executed by the system.

(4) Life cycle of activity

The boot order of an activity:

OnCreate ()-->onstart ()-->onresume ()

When another activity starts:

First activity OnPause ()--second activity onCreate ()-->onstart ()-->onresume ()

--First activity onStop ()

When you return to the first activity:

Second activity OnPause ()--First activity Onrestart ()-->onstart ()-->onresume ()--second activity onStop ()-- OnDestroy ()

2.Activity status

Activity is generally considered to have the following four states:

Active: When an activity is at the top of the stack, it is visible, focused, and acceptable to user input. Android tries to keep it active as much as possible, killing other activities to ensure that the active activity has enough resources to use. When another activity is activated, this will be paused.

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

When paused, an activity is still active, but it is not acceptable to user input. In very special cases, Android will kill a suspended activity to provide sufficient resources for active activity. When an activity becomes completely hidden, it will become a stop.

Stop: When an activity is not visible, it "stops". This activity will still save all its status and membership information in memory. However, when memory is needed elsewhere, it will be the most likely to be freed of resources. When an activity is stopped, an important step is to save the data and the current UI state. Once an activity exits or shuts down, it becomes a ready-to-use state.

To be used: After an activity is killed and put in front, it is ready to use. The pending acitivity is removed from the activity stack and needs to be restarted before it is displayed and available.

Recently, Love Beta (www.ineice.com) launched an activity component for mobile applications for security vulnerability detection

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android four components of activity introduction

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.