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
This time, I would like to share with you Ogilvy ...
...
Expert of this article: Han Hongyu, Associate Chi...
Eternal feminine, lead us upward. Das ewige weibl...
The long 2017 is finally over, and we are about t...
Since I joined Didi in August 2015, I have been r...
There are many experts on the Internet who have w...
Recently, there are new discoveries in the archae...
The 2015 Chinese New Year is approaching. While w...
Course Description The Calculus video tutorial co...
May and June every year are the fresh Cordyceps s...
"Viral" and "contagious" canc...
As bidders, we may also be familiar with the term...
Co-founder of Beijing Niu Technologies Co., Ltd. ...
"My heart is pounding, tell me what to do?&q...