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)