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();
  }
上一篇 下一篇

猜你喜欢

热点阅读