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
[[127970]] On the day Alibaba went public, Septem...
The peak season for pollen allergies is here agai...
For the upcoming Father's Day, many brands wi...
ASP.NET 5 is a revolutionary rewrite, all functio...
Weibo is a social networking platform with great ...
As the weather is still relatively dry, it is ver...
Windows Phone has been on the market for several y...
As soon as spring comes, all kinds of fruits begi...
[[130588]] Key [“IDST needs to do what other depa...
Course Catalog: 01. The Art of Naming Lecture 1.m...
Recently, a wave of new coronavirus infections ha...
Long build time will slow down the development pr...
One minute with the doctor, the postures are cons...
They live among us But I have a heart that can on...