Android system startup
1, "Introduction to the Android System Startup Process"
2, "Android init process startup process"
3. "Android zygote process startup process"
4. "Android SystemServer Process Startup Process"
5. "Android launcher startup process"
6. "Detailed Explanation of Android Activity Startup Process"
Android System Development Preparation
1, "Android Source Code Download and Compilation"
2. "Android 11 source code compilation and pixel3 flashing"
3. "Android Framework Code IDE Loading and Debugging"
Android System Development Practice
1. "Android Setting Default Input Method"
2, "android framework prefabricated APK application"
3. "Detailed Explanation of Restricting Apps from Starting at the Android System Level"
4. "Android compiles the framework module separately and pushes it"
5. "Android Framework Development System Problem Analysis"
Android System Development Core Knowledge Reserve
1, "Android Compilation System - envsetup and lunch code articles"
2. "Android Compilation System - Concept"
3. "Detailed Explanation of Android Log System"
4. "Android System Handler Detailed Explanation"
5. "Android System Binder Detailed Explanation"
6. "Detailed Explanation of the Relationship between Activity, View and Window in Android"
7. "Detailed Explanation of the Android View Drawing Process"
8. "Detailed Explanation of Android Reading System Attributes"
9. "Detailed Explanation of Android Window Management Mechanism"
10. "Acquaintance with Android System"
11. "The communication method of AMS process in android notifying Zygote process fork new process"
Detailed explanation of Android core functions
1. "Android application market click to download APK installation details"
2, "Android gesture navigation (swipe from bottom to top to enter the multitasking page)"
4. "Detailed Explanation of Android Application Installation Process"
5, "android11 installation application triggers desktop icon refresh process"
6. "Detailed Explanation of Android System Multitasking Recents"
7. "Android System Navigation Bar View Analysis"
———————————————————————————————————————————
Table of contents
Second, the relationship description
2.4 Relationship between Activity, PhoneWindow and DecorView
1. Background introduction
Window, Activity, and View are often used, but the relationship between the three is still not systematically clarified. Today we will start to sort out the relationship between the three:
Window: The abstract base class for top-level window appearance and behavior policies. The only implementation is the PhoneWindow class.
Activity: One of the four major components, it provides an interface for users to click and slide.
View: represents the basic building block of user interface components, UI components.
1.1 Activity
Activity is not responsible for view control, it just controls the life cycle and handles events. What really controls the view is the Window. An Activity contains a Window, and the Window really represents a window. Activity is like a human-computer interaction interface, coordinating the addition and display of views, and interacting with Window and View through other callback methods.
1.2 Window
Window
The understanding of is more abstract, Window
it is equivalent to a container, which "holds" a lot View
, and these View
are organized in a tree structure.
Window is an abstract class, and what is actually held in Activity is its subclass PhoneWindow. There is an internal class DecorView in PhoneWindow, by creating DecorView to load the R.layout.activity set in the Activity, Window is the carrier of the view, holds a DecorView inside, and this DecorView is the root layout of the view.
Window loads DecorView through WindowManager, and hands DecorView to ViewRoot for view drawing and other interactions.
1.3 View
In the android system, view is managed through a tree structure. The View tree structure is as follows,
Among them, DecorView is a subclass of FrameLayout, which can be considered as the root node view of the Android view tree.
DecorView is used as the top-level View. Generally, it contains a vertical LinearLayout. There are three parts in the LinearLayout. The above is a ViewStub, which is a lazy-loaded view (should be set to ActionBar, according to Theme settings), and the middle one is The title bar (according to the Theme setting, some layouts do not have it), and the content bar below.
Second, the relationship description
2.1 Activity and Window
Every time an Activity instance is created, then Activity.attach() is called to initialize some content. The Window object is created, initialized and assigned in attach. In attach(), the system creates the Window object to which the Activity belongs and sets a callback interface for it. Since Activity implements Window's Callback interface, when Window receives an external state change, it will call back to the Activity's method.
2.2 Window and View
Before understanding the relationship between Window and View, we need to know what ViewRoot (ViewRootImpl) is. It is the link between WindowManager and DecorView.
- ViewRoot is a manager of ViewTree, not the root node of ViewTree.
- Strictly speaking, the root node of ViewTree is only DecorView.
- ViewRoot "combines" DecorView and PhoneWindow (the Window instance created by Activity).
2.3 Window and View
View is the view presentation method in Android, but View cannot exist alone, it must be attached to the abstract concept of Window, so where there is a view, there is a Window.
The most familiar method is to call the setContentView() method in the Activity.onCreate() method and pass in the specified layout file. Activity hands over the specific implementation to Window, and the specific implementation of Window is that PhoneWindow creates DecorView in setContentView, and DecorView is the root View of the entire View tree, and then adds the formulated layout file to mContentParent of DecorView.
2.4 Relationship between Activity, PhoneWindow and DecorView
Activity and PhoneWindow and DecorView relationship diagram,