是否需要授予Android M中EXTERNAL_STORAGE所需的权限? [英] Grant permission required for EXTERNAL_STORAGE in Android M?

查看:229
本文介绍了是否需要授予Android M中EXTERNAL_STORAGE所需的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android权限WRITE_EXTERNAL_STORAGEREAD_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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆