Will the Android permissions WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
trigger the new grant permission dialog of Android M?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I agree with Guillaume Perrot 's answer. I have met the similar question when I write the permission of
READ_WRITE_EXTERNAL_STORAGE
inAndroidManifest.xml
with no permissions showing up in the app by default , people need to switch the toggle button of storage in the app permissions.Then I modify my
targetSdkVersion
inbuild.gradle
to less than23(MNC)
and other number related withsdkVersion
, the app installed with the permissions on.The other way is to write
requestpermission
function in the place that you need the permisson. The code is as follow:Because I have less than 15 reputation so I can't vote for the Guillaume Perrot 's answer.Just use this way to show my idea.
According to Android docs you don't need to request permission about read and write external storage.
Edit: in the latest Android M release you need to ask for both read and write permissions
I solved add this if check version for Android M
My answer is based on my tests on M Preview SDK version 2, using an emulator.
If you target
MNC
preview API level,WRITE_EXTERNAL_STORAGE
is not granted by default and will be part of the new dynamic permission API.You will see the storage permission as a toggle button in the new app permissions menu in device settings, and you can use
Activity.requestPermissions
to show the popup for that permission.However if you target api level < MNC, it won't be classified as a dangerous permission, and thus will be granted without a way for the user to disable it (not showing up in permission settings), and you will not be able to compile code using
Activity.requestPermissions
anyway as the preview SDK enforcesminSdkVersion="MNC"
to use the new APIs.This is a different behavior than location permissions: whatever the API level you target, the user will be able to turn location off in permission menu.
For the permission menu itself, the permission toggle state is ON by default if:
Otherwise you will see the toggle as OFF by default.
Hope it helps.
Storage permission falls under dangerous protection level, So all the dangerous protection level permissions will not be granted at install time in Android M, if App target SDK is set to 23. They will be given at run time. And yes these permissions can be revoked at run time also.
No permission dialog will not be triggered automatically, you need to do a request by using API such as requestPermissions() method to show that native dialog.
Please check the dangerous level permission list here
According to the docs:
So because READ_EXTERNAL_STORAGE is falling under PROTECTION_NORMAL , it won't trigger the dialog.
But because the level of WRITE_EXTERNAL_STORAGE is PROTECTION_DANGEROUS, it will fall under this behavior as described in docs:
Here is the sources for the protection level:
detailed list