Android permissions are set by default and application doesn't know if they are off

混江龙づ霸主 提交于 2019-12-08 05:36:09

问题


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

回答1:


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.




回答2:


I had a similar problem. What seems to have resolved my issue was changing the Project options in Xamarin. In the Android Application tab of the project options, I had "Automatic - use target framework version (API 24)" selected for Target Android version, when I changed it to "Override - Android 7.0 (API 24)" it seems to have resolved the issue.




回答3:


Apparently you need to set and explicit targetSdkVersion, Automatic seems to result in < 23 behavior.



来源:https://stackoverflow.com/questions/40002460/android-permissions-are-set-by-default-and-application-doesnt-know-if-they-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!