ActivityThreadActivityThread is an important component in the Android system that is responsible for managing and scheduling Activities in applications. Essence and function:
Main Responsibilities:
Initialization process:
Member variables and methods:
The main responsibilities of the main thread are:
ApplicationThreadApplicationThread is an inner class of ActivityThread and is a Binder object. ApplicationThread acts as the server side of the IApplicationThread object, waiting for client requests and then processing them. The largest client is AMS. ApplicationThread plays an important role in the Android application startup process. When the handleBindApplication method of ActivityThread is called, ApplicationThread will be bound to the Application object as a bridge for communication between the application and system services. The handleBindApplication method will also call the onCreate method of the Application object, which is the first callback method in the application startup process. In the process of starting the Activity, the ScheduleActivity method of ApplicationThread sends a message to start the Activity through a Handler called H. ActivityThread is also known as the UI thread or main thread. It is the entry point of the program (main function) and saves all the corresponding components of the application (such as activities, services, and content providers, etc.). Create the root Activity: picture The Launcher process requests AMS to create a root Activity. AMS determines whether the application process required by the root Activity exists and starts it. If it does not exist, it requests the Zygote process to create the application process. After the application process is started, AMS requests the application process to create and start the root Activity. Create a normal Activity: picture The Activity in the application process requests AMS to create a normal Activity (step 1). AMS will manage the life cycle and stack of this Activity, verify (AndroidManifest.xml registration file declaration, start permission) Activity, etc. If the Activity meets the AMS verification (judgment process exists), AMS will request the ActivityThread in the application process to create and start a normal Activity. picture SummarizeApplicationThread is an inner class of ActivityThread, which implements the IApplicationThread interface, a Binder interface used for inter-process communication (IPC). As the server of IApplicationThread, the ApplicationThread object is called by system services such as AMS through the Binder mechanism. ActivityThread is the main thread of the Android application process, which is what we usually call the UI thread. Each Android application process has an ActivityThread instance, which is responsible for creating and managing application components (such as Activity, Service, BroadcastReceiver, etc.) and handling life cycle events related to these components. ApplicationThread and ActivityThread are closely related. ApplicationThread is an inner class of ActivityThread, which is used to handle IPC calls from AMS and convert these calls into calls to corresponding methods in ActivityThread. AMS communicates with ActivityThread through ApplicationThread to manage the life cycle and components of the application. |
<<: Is there a bug in iOS 17.5? Users’ private photos reappear after being deleted!
>>: Android process management: How to terminate the process during development
Duke Zhou, a founding hero of the Western Zhou Dy...
[[437761]] Whenever friends share good things fro...
□ Feng Weimin Sponges are the most primitive mult...
This article is a summary of the book "The B...
The temperature in Beijing keeps dropping. People...
Recently, an 11-year-old boy in Guangdong suffere...
On January 9, the iPhone was born 10 years ago, a...
The sudden outbreak of the epidemic has disrupted...
The current Lexus LS has been launched for more t...
The picture shows the Jimu-1 III airship in front...
For Huawei, the most noteworthy product at the mo...
How much does it cost to develop a catering mini ...
Speaking of OLED, the industry believes that it i...
Recently, Audi China, the Audi Dealer Association...
Android Studio 1.0 RC is released and available i...