Android ContextCompat.checkSelfPermission () returns invalid value

I am trying to check if user permissions are granted / revoked in Android Marshmallow. Unfortunately, ContextCompat.checkSelfPermission() (which is warpper around Context.checkCallingOrSelfPermission ), as always, returns PackageManager.PERMISSION_GRANTED (0) if you included this specific permission in the manifest, regardless of the current permission state (for example, if the user revoked the permission ) I also tried someContext.checkCallingOrSelfPermission() , but the result is the same.

Has anyone experienced this? I am using Android Marshmallow on the nVidia Shield console (using the nVidia beta).

+7
android android-6.0-marshmallow permissions
source share
1 answer

As it turned out, the TargetSdkVersion in the manifest should be 23, mine was 22. If your target SDK is 23 (Android 6), all permissions (in your manifest) are disabled by default, whereas if your target SDK is 22 (Android 5.1), and your application runs on Android 6, all permissions are enabled by default when the user installs the application, and even if the user revokes the permissions later, the mentioned API returns an invalid value (which is an error, in my opinion).

+9
source share

All Articles