Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WRITE_EXTERNAL_STORAGE not granted

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
}
like image 538
user982687 Avatar asked Sep 01 '25 15:09

user982687


1 Answers

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.

like image 98
user982687 Avatar answered Sep 04 '25 06:09

user982687