code: public boolean isPermissionGranted(@NonNull Activity activity, @NonNull String permission) {
          Log.v(TAG, String.format("Checking if %s permission is granted.", permission));
          int result = ContextCompat.checkSelfPermission(activity, permission);
          return result == PermissionChecker.PERMISSION_GRANTED;
      }
docs: Checks if the given Android Manifest Permission has been granted by the user to this application before.
  
  @param activity   the caller activity
  @param permission to check availability for
  @return true if the Android Manifest Permission is currently granted, false otherwise.