方法一:
public boolean isMainThread() {return Looper.getMainLooper().getThread() == Thread.currentThread();
}方法二:
public boolean isMainThread() {
Looper looper = Looper.myLooper();
if (looper == null) {return false;}return looper == Looper.getMainLooper() ;
}