美文网首页
android常用方法总结

android常用方法总结

作者: ModestStorm | 来源:发表于2020-06-11 17:44 被阅读0次

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();
  }

相关文章

网友评论

      本文标题:android常用方法总结

      本文链接:https://www.haomeiwen.com/subject/ioxitktx.html