public static boolean isUriRequiresPermissions(@NonNull Context context,@NonNull Uri uri){
  try {
    ContentResolver resolver=context.getContentResolver();
    InputStream stream=resolver.openInputStream(uri);
    stream.close();
    return false;
  }
 catch (  Exception e) {
    return true;
  }
}

public static boolean isUriRequiresPermissions ( @ NonNull Context context , @ NonNull Uri uri ) { try { ContentResolver resolver = context . getContentResolver ( ) ; InputStream stream = resolver . openInputStream ( uri ) ; stream . close ( ) ; return false ; } catch ( Exception e ) { return true ; } }
test if we can open the given android uri to test if permission required error is thrown . < br > only relevant for api version 23 and above .
