Looper.myLooper() == Looper.getMainLooper() 是可以帮助你确定你是否在主线程的代码。
Looper.myLooper() == Looper.getMainLooper()