- In the Android program, each Activity inherits from Android.app.Activity,
- There is an XML layout file that corresponds to it,
- One interface corresponds to an activity,
- Each activity needs to be registered in the Androidmanifest.xml
- Activity organizes controls by layout management
- The controls in each activity will correspond to the R files.
- defined in the XML layout file, android:id= "@+id/thisisbutton"
- Each control in the layout file has a corresponding class, with the button example, in the layout file for <button/> Its corresponding class as button
- Use button button = (button) Findviewbyid (R.id.thisisbutton) reference in activity
- Jumps between the activity
- Use the startactivity (Intent Intent) method to open another activity
- Before opening, you can pass parameters by storing variables in the intent.
- Create a new activity to jump to
- To bind a button to an event
- Create a new intent and point to the corresponding activity to complete the page jump
- You can populate the intent with data before jumping
Normal types can be passed between activity, and wrapper classes cannot be passed.
- Complete
|
Method |
Call timing |
|
OnCreate |
Called when an activity is created |
|
OnStart |
Immediately after the call is created, the activity is about to become visible |
|
Onrestart |
Called when it is back to activity, and then calls start after the call is completed. |
|
Onresume |
The activity is ready to be called when user action is accepted |
|
OnPause |
To switch to another activity call, which is particularly useful for saving some of the current activity's data |
|
OnStop |
Called when the current activity is overwritten by another activity |
|
OnDestroy |
Called when the activity is destroyed |
- Activity Life Cycle Classification
- Full life cycle
- Visual life cycle
- Foreground life cycle
- Activity and Task
Accessing multiple activity forms an activity chain in order, called task,android, to manipulate tasks in the form of a stack.
Activity is run according to the rules of the stack.
Android Basic Components-activity