In the Android system, the class handler has the following two functions mainly.
Sends a message in a newly-started thread.
Gets and processes the message in the main thread.
Class handler When you do this, you first send a message in a newly-started thread, and then you get and process the message in the main path. But
This process involves a problem: when does a newly-started thread send a message? When does the main thread get and process messages? The timing is clearly not in control.
In order for the main program to "timely" handle the message sent by the newly-started thread, it is clear that the callback is the only way to implement it-developers simply rewrite the handler class
The method that processes the message, and when the newly-started thread sends a message, the message is sent to the MessageQueue associated with it, and handler continuously fetches and processes the message from MessageQueue.
That is, the method that processes the message in the handler class is callback.
The Android system does not allow access to the interface components in the activity in the new thread, so the program can only send a message to the new thread informing the system to update the UI.
Android Handler Message delivery mechanism