Android applications are driven by messages , and the system maintains a message team example (Mesagequeue)for each application, and the main thread of the application constantly gets messages from this message team example (Mesage), These messages are then processed (Handler), which enables the execution of the application to be driven by messages.
When Activitymanagerservice needs to interact with the app, such as loading activity and service, processing the broadcast, the application is notified through the binder interprocess communication mechanism, and the application receives the request , it does not immediately process the request, but encapsulates the request as a message, then puts the message in the application's message queue and then processes the message through the message loop. The advantage of this is that the sender of the message simply sends the message to the application's message queue, and it can go back to handling something else immediately, without waiting for the message receiver to process the message before returning , which can improve the concurrency of the system. Essentially, this is an asynchronous processing mechanism.
Android Handler, Lopper message-driven mechanism