Overview:
Many Android beginners to Android handler is not very clear, in fact, Google reference the Windows message processing mechanism,
A similar message-handling mechanism was implemented in the Android system. Before introducing the handler mechanism, here are a few concepts to understand:
1. Message
Messages, which are understood as data units for inter-thread communication. For example, a background thread that needs to update the UI after processing the data can send a message containing the update information to the UI thread.
2. Message Queue
Message Queuing, used to store messages published through Handler, followed by FIFO execution.
3. Handler
Handler is the primary processor for message, which is responsible for adding messages to message queues and processing messages in message queues.
4. Looper
The circulator, acting as a bridge between the message queue and the handler, loops out the message within the message queue and delivers it to the corresponding handler for processing.
5. Threads
The UI thread is usually the main thread, and the Android launcher will create a message Queue for it.
Each thread can contain a Looper object and a MessageQueue data structure. In your application, you can define handler subcategories to receive messages sent by Looper.
Okay, here's the text ~
An explanation of the mechanism and usage of handler in Android