Can anyone tell me if there's any difference between using runOnUiThread()
versus Looper.getMainLooper().post()
to execute a task on the UI thread in Android??
The only thing I can determine is that since runOnUiThread is a non-static Activity method, Looper.getMainLooper().post()
is more convenient when you need to code something in a class that can't see the Activity (such as an interface).
I'm not looking for a discussion on WHETHER something should be executed on the UI thread, I get that some things can't and a great many things shouldn't, however, some things (like starting up an AsyncTask) MUST be executed from the UI thread.
runOnUiThread
will check if it is already the UI thread and execute your task directly instead of posting it as aMessage