(1) Key points for creating activity
1. An activity is a class, and this class inherits activity
2. Need to rewrite the OnCreate method
3. Each activity must be configured in a Androidmanifest.xml document
Note: When the following code is configured in the activity, the activity is executed first
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
4. Add the necessary controls for the activity
(2) The basic function of intent
A Intent object contains a set of information:
ComponentName (important) Role: according to componentname information to decide which activity,service to launch, broadcast recipient, etc.
Action (IMPORTANT): Specify what the other activity will do
Data (important) Role: How to transfer information from one activity to another
Category
Extras (important) Effect: Transfer key value pairs from one activity to another activity through intent, then take it out
Flags
(3) The method of initiating another activity in one activity
Using listeners
......
Intent intent=new Intent ();
Intent.putextra ("Testintent", "123")//Transmit data with intent
Intent.setclass (Activity01.this,activity02.class); Indicates booting from ACTIVITY01 Activity02
StartActivity (Intent); Start Activity02 and perform the operation inside
(4) Basic method of using intent to transfer data between activity
See details (3)
To receive the Activity02 in the ACTIVITY01.123
Intent intent=getintent ();
String Value=intent.getstringextra ("testintent");
Mytext.settext (value);//Use the existing text to show the Activity01 pass over 123
(5) Life cycle of Activity
public class Activity extends applicationcontext{
Protected void OnCreate (Bundle savedinstancestate); When the first call to an activity is performed on this method
Protected void OnStart (); After the OnCreate is executed, the OnStart method is executed if the activity courseware
Protected void Onresume (); Call the Onrestart method if the activity can get the user's focus
"Note": When the above three methods are called, the activity can be manipulated and used.
Protected void OnPause (); After executing the first three methods above, if there is a call to 21 activity at this time, execute the first activity's OnPause method, then execute the second onCreate (), OnStart (), and, Onresume () method, The OnStop () method that invokes the first activity (but also not absolute, special case see next)
Protected void OnStop ();//When the second activity that is started completely obscures the first activity, the first activity is called, otherwise only the first OnPause () method is called
Protected void Onrestart (); When the first activity is returned from the second activity, the first activity's Onrestart () method is called, and then the first activity's Onresume () method is called to display the first activity
Protected void Ondestrory ();//When the second activity's OnStop () method is called for some reason (e.g., memory shortage), the second activity's Ondestrory () method is called, The second activity will be destroyed.
}
Android Notes (1)