我需要检查,如果运行的某一块code线程的主(UI)线程上运行与否。我怎样才能做到这一点?
解决方案 Looper.myLooper()== Looper.getMainLooper()
如果返回true,那么你是在UI线程!
I need to check if the thread running a certain piece of code is running on the main (UI) thread or not. How can I achieve this?
解决方案Looper.myLooper() == Looper.getMainLooper()
if this returns true, then you're on the UI thread!