Reputation: 335
I have the WRITE_EXTERNAL_STORAGE permission designated in the manifest, and in the app when I call requestPermissions, the grantResult comes back with -1, meaning it's not granted. However, in Device Settings for the app, the Storage permission is showing as ON. The app will not let me write, however. Why is the grant request failing, and the permission denied as far as the app is concerned, but showing as fine in Settings?
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, PICK_FROM_GALLERY);
.
.
.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, RESULT_LOAD_IMAGE);
} else {
//THIS IS WHERE I END UP WITH grantResults == -1
}
Upvotes: 4
Views: 5118
Reputation: 4207
May my case help somebody as I noticed a space in my permission in manifest, it was <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/>
and I changed it to <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
and problem solved. no any other change.
Upvotes: 0
Reputation: 335
I found the answer. Evidently, something I'm pulling in from a 3rd party lib is causing a manifest merger. By adding this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>
my problem goes away.
Upvotes: 8