问题
I have added READ and WRITE storage permission to my android app in the manifest. I am using these permission to access the gallery images for some purpose. But when I am checking the app info for my application in android setting, the storage permission selector is not available in the app info page. However, all other permission selectors are there.
My Question is not about how I ask for permission on the marshmallow. I have already defined runtime permissions in my code. Also all required uses-permission in the manifest file also. But still, I am not getting storage permission in app info of android settings.
回答1:
I don't know what the problem was but I have solved my problem by putting a tag on the permission in the android manifest class itself.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/>
回答2:
Here is my piece of code how i check for permission is already allowed or not.
When user click on camera or storage call this function:
//>=Marshmallow(23) needs app to request run-time permissions to use some features.
if (Build.VERSION.SDK_INT >= 23) {
if (checkPermission()) {
//permission to use Camera is already granted, now pick image
open camera or file picker
} else {
//App can still ask user for permission.
requestPermission();
}
}
checkPermission function:
private boolean checkPermission() {
int result = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
return result == PackageManager.PERMISSION_GRANTED;
}
Here is requestPermission function:
private void requestPermission() {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_REQUEST_CODE);
}
Manifest File:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Edit: Also to answer your question, by this way i can see storage permission in application permission settings.
来源:https://stackoverflow.com/questions/51149210/storage-access-permission-is-not-visible-in-app-info