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
Hughes short video system operation course, you w...
Document libraries are a major way to spread info...
Digging "soil" from outer space to draw...
[[144355]] There are two ways to write iOS applic...
Kuaishou Big Data Research Institute released the...
The Gregorian calendar year 2024 is a leap year, ...
Toyota has made a lot of moves recently: cooperat...
Taobao’s Daily Specials is a Taobao event that ma...
This article mainly wants to share with you my pe...
Source: Minitory This article has been authorized...
Recently, Renren Film Subtitle Group posted a mic...
——How to operate an event with little money and l...
From November 21 to 22, 2014, the 2014 WOT Global...
With the recent recurrence of the epidemic, many ...