标签:
在Android 中判断当前的Thread是否是UI Thread 的方法:
1.
if (Looper.myLooper() == Looper.getMainLooper()) { // Current thread is the UI/Main thread }
2.
if (Looper.getMainLooper().getThread() == Thread.currentThread()) { // Current thread is the UI/Main thread }
参考如下文章:其中还讲到了 runOnUiThread() 方法的用法。
http://codetheory.in/checkdetect-whether-current-thread-uimain-thread-android/
http://lak4cyut.blogspot.jp/2011/03/android-tip-activityrunonuithread.html
Android 判断当前thread 是否是UI thread
标签:
原文地址:http://www.cnblogs.com/igoogleyou/p/androidoo.html