Karrde Karrde -4 years ago 137
Android Question

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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download