在 Android M 中授予 EXTERNAL_STORAGE 所需的权限? [英] Grant permission required for EXTERNAL_STORAGE in Android M?
问题描述
Android 权限WRITE_EXTERNAL_STORAGE
和READ_EXTERNAL_STORAGE
会触发Android M 新的授予权限对话框吗?
Will the Android permissions WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
trigger the new grant permission dialog of Android M?
推荐答案
我同意 Guillaume Perrot 的回答.当我在 AndroidManifest.xml
I agree with Guillaume Perrot 's answer. I have met the similar question when I write the permission of READ_WRITE_EXTERNAL_STORAGE
in AndroidManifest.xml
默认情况下应用中没有显示权限,人们需要在应用权限中切换存储的切换按钮.然后我在build.gradle
中修改我的targetSdkVersion
> 小于 23(MNC)
和其他与 sdkVersion
相关的数字,应用程序安装的权限.
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
in build.gradle
to less than 23(MNC)
and other number related with sdkVersion
, the app installed with the permissions on.
另一种方式是在需要权限的地方写requestpermission
函数.代码如下:
The other way is to write requestpermission
function in the place that you need the permisson. The code is as follow:
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)==
PackageManager.PERMISSION_GRANTED) {
//do the things} else {
requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
AnyNumber);
因为我的声望不到 15,所以我不能投票给 Guillaume Perrot 的答案.就用这种方式来表达我的想法.
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.
这篇关于在 Android M 中授予 EXTERNAL_STORAGE 所需的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!