Talk about the understanding of Android (Activity)

Source: Internet
Author: User

Activity principle:

  Calls between. Java.xml.resource (data):

Java can get resource data through an XML layout file, Value/string.xml. There's something else. Java.this.getResource (). * * * (Location of data resources in R files)

  Activity kit is divided into five parts

R file

. xml file

. java file

Manifiest Registration

Resource Location

Life cycle of activity:

  Let's talk about activity introduction:

Activity is an interface system, as long as the interface system consists of three parts: control, layout, events;

An activity instance refers to its object, which is instantiated by the Android system itself, and is covered with an interactive interface that is filled with the entire window, or suspended on top of other windows. is an independent program interface; A program usually has multiple activity components, Will designate a master activity in the manifest.xml.

   The following code is visible:

<Activityandroid:label= "@string/app_name" Android:name= ". Mainactivity "><intent-filter>    <action android:name=" Android.intent.action.MAN "/>    < Category android:name= "Android.intent.category.LAUNCHER"/></intent-filter></activity>

Principle: When the other activity is started, the new activity is pushed into the stack, and the user focus is acquired, this time it can be manipulated on the new activity, the original activity lost focus becomes not operational.

  3 phases of the activity life cycle

    Open: onCreate (); OnStart (); Onresume ();

Regain focus: Onrestart (); OnStart (); Onresume ();

Closed: OnPause (); OnStop (); OnDestroy ();

  Seven Ways of Life cycle:

OnCreate ();

OnStart ();

Onrestart ();

Onresume () '

OnPause ();

OnStop ();

OnDestroy ();

  Two sub-loops, sub-lifecycles

The first layer (inner layer) loop is the life cycle of the focus, which loops through the focus of the current activity and loses, during which the activity is always visible-----onPause ()->onresume ()->onpause ()

The second layer (outer) loop is the activity cycle, which is the current activity looping between visible and invisible-----onStart ()->onresume ()->onresume ()->onpause () OnStop ()

  Life Cycle Division:

Overall life cycle: OnCreate ()->...-ondestory ()

Visual life cycle: OnStart ()->...->onstop ()

Focus life cycle: Onresume ()->onpause ()

The following is the full activity diagram:

    

Talk about the understanding of Android (Activity)

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.