简体   繁体   English

Android WRITE_EXTERNAL_STORAGE 未授予

[英]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.我在清单中指定了 WRITE_EXTERNAL_STORAGE 权限,在应用程序中,当我调用 requestPermissions 时,grantResult 返回 -1,这意味着它没有被授予。 However, in Device Settings for the app, the Storage permission is showing as ON.但是,在应用程序的设备设置中,存储权限显示为 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
}

I found the answer.我找到了答案。 Evidently, something I'm pulling in from a 3rd party lib is causing a manifest merger.显然,我从 3rd 方库中提取的东西正在导致明显的合并。 By adding this:通过添加这个:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/> 

my problem goes away.我的问题消失了。

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.我的情况可以帮助某人,因为我注意到清单中我的许可中有一个空格,它是<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/>并且我将其更改为<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>问题解决。 no any other change.没有任何其他变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM