Activity of Android four components

Source: Internet
Author: User

1. Perceptual Cognitive activity

Activity is one of the four components of Android, which is like a container with many Android layouts that can be written directly in the XML layout file referenced by the activity. It can also be shown in the activity in the form of fragment fragments. All in all, activity is like a team, with a diverse group of people who are managed by the team.

Creation of 2.Activity

First we open our development environment, and then create a class, the class name can be random, after the creation of a successful we enter the class, let the class inherit from the activity, let us also in the androidmenifest is the manifest file to register the activity. Such a class is created even if it is done.

Life cycle of 3.Activity usage

When it comes to activity, we all know that activity has its own declaration cycle, and the activity's declaration cycle can be well explained by these seven methods:

1.onCreate ()

2.onStart ()

3.onResume ()

4.onPause ()

5.onStop ()

6.onRetart ()

7.onDestroy ()

4.Activity use of the start mode

When the activity is created, we need to start the activity, which is launchmodule. After the activity has been created, it is stored in a task stack, which is the task stack, the task stack has a feature is that it is detached from the various applications of a thing, not belong to an application. We all know that activity is stored in the task stack, so when we need some activity, we need to go to the task stack to start. There are generally four modes for starting activity:

The first type: standard

The second type: Singletask

The third type: Singletop

Fourth type: SingleInstance

The interaction between 5.Activity

It is not possible to use only one activity between an application, and an application must contain multiple activity, so how does the activity interact?

First, we need a intent object, if there is data interaction, we also need a Bindle object, with the Bindle object to bind the data, let the same Bindle object into the intent object, and finally through the startactivity () method to start the intent object and jump to another activity to achieve interaction between the two activity.

Activity of Android four components

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.