This problem is big factory more than asked again, in fact, is to examine whether there is really read the source code here.
Direct source code
The loop() in Looper.java contains the code to distribute the message. The target is the handler that sends the message
Follow through and that’s how you distribute it, as shown by the arrow
There are three distribution paths
1. Let’s start with the last handleMessage, the one you’re most familiar with, which is the handleMessage we override when we define handler.
The first arrow callback is handler.post(runnable) and the runnable is assigned to it. Don’t believe it? Let me bring up the source code
Pick up any post code and follow it
Enter the getPostMessage
Well, this is where callback is assigned
3. Where does the mCallback of the second arrow go? Where does it get assigned?
The Handler class has a number of constructors, including one with a callback, as shown below
What does this Callback look like
It also defines a handleMessage, similar to the third arrow.
So just to conclude
- MSG. Callback is the runnable that was posted
- The mCallback is the callback passed in by the Handler constructor
- The handlerMessage is overwritten normally