Putting it simply, there are Looper threads, for example, a UI thread. Such a stream has its own Looper , which starts a message loop for the stream.
Such a thread, as a rule, has a Handler that processes Looper messages - overrides public void handleMessage(Message msg) or runs a Runnable that has been sent to the loop message queue.
When you create a Handler in the context of the user interface thread (as in your code), it is associated with the loopback mechanism of the user interface thread, so your \\someCode works in the user interface thread.
I assume that in your case, the use of new Handler().post(Runnable) and View:post(Runnable) is basically the same, since both add Runnable to the message queue of the UI thread.
But they are not the same.
View:post(Runnable) will add Runnable to the message queue of the user interface thread looper;Handler:post(Runnable) will add Runnable to its associated message queue message flow
My explanation is pretty much intuitive, so correct me if I'm wrong.
Drew
source share