code: public static boolean isPermissionGranted(@NonNull Context context, @NonNull String permission) {
          return ActivityCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
      }
docs: return true if permission is granted, false otherwise.
  <p/>
  can be used outside of activity.