code: public boolean areAllRequiredPermissionsGranted(String[] permissions, int[] grantResults) {
          if (permissions == null || permissions.length == 0
                  || grantResults == null || grantResults.length == 0) {
              return false;
          }
  
          LinkedHashMap<String, Integer> perms = new LinkedHashMap<>();
  
          for (int i = 0; i < permissions.length; i++) {
              if (!perms.containsKey(permissions[i])
                      || (perms.containsKey(permissions[i]) && perms.get(permissions[i]) == PackageManager.PERMISSION_DENIED))
                  perms.put(permissions[i], grantResults[i]);
          }
  
          for (Map.Entry<String, Integer> entry : perms.entrySet()) {
              if (entry.getValue() != PackageManager.PERMISSION_GRANTED) {
                  return false;
              }
          }
  
          return true;
      }
docs: Method to call inside
  {@link Activity#onRequestPermissionsResult(int, String[], int[])}, to check if the
  required permissions are granted.
  @param permissions permissions requested
  @param grantResults results
  @return true if all the required permissions are granted, otherwise false