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 == Pac开发者_开发问答kageManager.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.
精彩评论