android常用方法总结
2020-06-11 本文已影响0人
ModestStorm
1.是否在主线程判断
/** Returns {@code true} if called on the main thread, {@code false} otherwise. */
public static boolean isOnMainThread() {
return Looper.myLooper() == Looper.getMainLooper();
}
/** Returns {@code true} if called on a background thread, {@code false} otherwise. */
public static boolean isOnBackgroundThread() {
return !isOnMainThread();
}