棉花糖权限不低于23工作TargetVersion [英] Marshmallow Permissions not working for TargetVersion below 23

查看:184
本文介绍了棉花糖权限不低于23工作TargetVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是一个长期运行的项目。我已经设定目标版本为10,4岁了。我不能在目标的版本改为23,因为我使用httpImageCache,也有与UI的问题。我的问题是,当棉花糖发布我试图与棉花糖10 targetVersion整合,

My project is a long running project. I had set the target version as 10, 4 years back. I cant change the target version to 23, since I am using httpImageCache and also having issues with UI's. My problem is, when Marshmallow released I tried to integrate Marshmallow with targetVersion 10,

 int returnedPermission = ContextCompat.checkSelfPermission(MyActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE);

此功能总是returing'0'如果我手动开启或从应用程序设置页面关闭的存储权限。任何一个可以帮帮我吗?

this function is always returing '0' if I manually ON or Off storage permission from App Settings page. Can any one please help me?

推荐答案

由于@Commonware已经给出了答案,但在这里我增加更多的细节可能帮助你的问题。
根据官方Android开发者网站:

As @Commonware has already given the answer, but here I am adding more detail to the question which might help you. As per the official android developer site:


  • 如果设备运行的是Android 5.1或更低,或者您的应用程序的目标
    SDK是22或更低
    :如果您列出一个危险的权限
    清单,在用户,当他们安装应用程序授予许可;如果他们不授予权限时,系统不会安装的应用程序都没有。

  • If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.

如果设备运行的是Android 6.0或更高版本,以及您的应用程序的目标
SDK是23或更高版本:应用必须列出的权限
体现,并且它必须请求它需要在每个危险权限
而应用程序正在运行。用户可以授予或拒绝每个权限,
和应用程序可以继续使用能力有限,即使运行
用户拒绝了权限要求。

If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.

作为目标SDK是10,应用程序将完美运行像previous。无论如何,请注意,用户仍然后可以撤销许可.. !!!虽然在Android 6.0提醒用户,当他们尝试这样做,但他们可以撤销反正

As your target SDK is 10, application will run perfectly like previous. Anyway please note that user still can revoke a permission after that..!!! Although Android 6.0 warn the user when they try to do that but they can revoke anyway.

上面的语句从官方Android开发者网站服用。

这篇关于棉花糖权限不低于23工作TargetVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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