Android权限是默认设置的,应用程序不知道它们是否已关闭 [英] Android permissions are set by default and application doesn't know if they are off

查看:134
本文介绍了Android权限是默认设置的,应用程序不知道它们是否已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了xamarin android,现在使用7.0版(牛轧糖)编译了应用程序.但是当我在6.0.1(棉花糖)上部署应用程序时,所有权限都已设置.当我从设置中关闭位置权限时,警报显示此应用是为较早版本的android设计的.拒绝权限可能导致其不再正常运行".然后,如果我们拒绝权限,并且应用程序中的方法Context.CheckSelfPermission仍然返回Permission.Granted. 这是xamarin问题还是SelfPermission行为发生了某些变化?

I updated xamarin android and now compile app using version 7.0(Nougat). But when I deploy app on 6.0.1(marshmallow), all permissions are already set. When I turn off location permission from settings, alert displays "this app was designed for an older version of android. denying permission may cause it to no longer function as intended". Then if we deny permission and method Context.CheckSelfPermission in the app return Permission.Granted anyway. Is this xamarin issue or something change in SelfPermission behaviour?

Application.Context.CheckSelfPermission(Manifest.Permission.AccessCoarseLocation) == Permission.Granted//returns true, even if permission is off     
 Application.Context.CheckSelfPermission(Manifest.Permission.AccessFineLocation) == Permission.Granted//returns true, even if permission is off

推荐答案

我的解决方案是将清单中的目标SDK设置为23.这样,它告诉设备您已经为此API级进行了测试,因此AppCompat方法CheckSelfPermission将起作用.

My solution was to set the target SDK to 23 in the manifest. This way, it tells the device that you have tested for this API level, therefore the AppCompat method CheckSelfPermission will work.

这篇关于Android权限是默认设置的,应用程序不知道它们是否已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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