Putting it simply, there are Looper threads, for example, UI thread. Such thread has its own Looper, which runs a message loop for the thread.
Such thread, typically, has a Handler, which processes its Looper
's messages - overriding public void handleMessage(Message msg)
or executing a Runnable
, which was posted to it's looper's message queue.
When you're creating a Handler
in the context of UI thread (like you did in your code), it gets associated with UI thread's looper, so your \\someCode
runs on UI thread.
I guess, in your use case new Handler().post(Runnable)
and View:post(Runnable)
are mostly the same, as they both add a Runnable
to the UI thread message queue.
But they are not the same.
View:post(Runnable)
will add aRunnable
to the UI thread looper's message queue;Handler:post(Runnable)
will add aRunnable
to its associated thread looper's message queue
My explanation is pretty much intuitive, so correct me anyone if I am wrong.