问题
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