最佳答案
有人能告诉我在 Android 的 UI 线程上使用 runOnUiThread()
和使用 Looper.getMainLooper().post()
执行任务有什么区别吗?
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).
我不是在讨论是否应该在 UI 线程上执行某些东西,我知道有些东西不能,很多东西不应该,但是,有些东西(如启动一个 AsyncTask)必须从 UI 线程上执行。