I have tried the following but this always returns PackageManager.PERMISSION_DENIED although I know that I have the right to read the file. Any ideas?
Uri uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM);
// check uri permissions but does not work
int perm = checkUriPermission(uri , "r", null,
Binder.getCallingPid(), Binder.getCallingUid(),
Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (perm == PackageManager.PERMISSION_DENIED) {
Toast.makeText(getApplicationContext(),
"No permissions to read the file", Toast.LENGTH_LONG).show();
finish();
}
r is not a permission. Try passing null for the second parameter, or use the version of checkUriPermission() that skips the two String parameters you have in the second and third positions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With