I'm testing denial of permission to an application and I'm seeing that when asking for the state of the permission it returns granted instead of denied.
I'm checking state of permissions according to Google's Guide:
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
Manifest.permission.CAMERA)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.CAMERA},
PERMISSIONS_REQUEST_TAKE_PHOTO);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
Here is what it actually returns in the first if:
State "0" means PackageManager.PERMISSION_GRANTED
This is generating a java.lang.RuntimeException: Fail to connect to camera service
error.
DEVICE IS A NEXUS 5X
Best regards.