方法一:
public boolean isMainThread() {
return Looper.getMainLooper() == Looper.myLooper();
}
方法二:
public boolean isMainThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
方法三:
public boolean isMainThread() {
return Looper.getMainLooper().getThread().getId() == Thread.currentThread().getId();
}
PS:有更好的方法欢迎留言!