Android Activity principle and its subclass description
Introduction
Activity is an Android application component that implements a user interaction window. We can fill the screen with la s or implement floating windows. An app is composed of multiple Actvitiy types, which use intent-filter to differentiate the primary-secondary relationship.
The following describes the Activity and its subclass and Other interfaces.
Details 1. Activity
2. ListActivity
3. ActivityGroup
4. TabActivity
5. PreferenceActivity
6. FragmentActivity
7. ListFragment
8. NativeActivity
9. ExpandableListActivity
10. LauncherActivity
11. AliasActivity
12. PreferenceFragment
13. ActivityCompat
14. ActivityUnitTestCase
Currently, Activity management involves two classes: 1. LocalActivityManager 2. ActivityManager. What have they done separately?
Lifecycle
The background thread for downloading data, so it may create this thread in onCreate () and stop this thread in onDestroy.
The life cycle is visible from the onStart () of the activity call to the onStop () of the call. During this period, the user can see the activity on the screen, although it is not necessarily in the foreground and may not interact with the user. Between the two methods, you can maintain the resources required for the activity to be displayed by the user. For example, you can register an IntentReceiver in onStart () to monitor environment changes that can affect your UI, when your UI is not displayed in front of the user, you can log out the IntentReceiver in onStop. The corresponding method is called whenever the activity is displayed or hidden in front of the user. Therefore, the onStart () and onStop () methods can be called multiple times throughout the lifecycle.
Starting from the onResume () call of the activity and calling the corresponding onPause (), the activity is called the foreground life cycle. During this period, the activity is in front of all other activities and interacts with the user. An activity can often switch between the resumed and paused States-for example, when the mobile phone goes to sleep, the activity results are returned, and the new intent arrives-so the code in the two methods should be very short..
The following Activity method defines the complete lifecycle of an activity. They are all hook methods. You can reload these methods to make the activity execute the operations you expect when the status changes. All activities should implement their own onCreate (Bundle) method for initialization settings; most of them should also implement the onPause () method to submit data modifications and prepare to terminate interaction with users. Although we plan to add more tools to the system to manage applications, most of the current activities still need to implement onFreeze () and perform corresponding state recovery in onCreate (Bundle. Other methods can be implemented as needed. when implementing these methods, you must call the corresponding methods in the parent class.