When I request a permission (in this case Manifest.permission.ACCESS_FINE_LOCATION
or "android.permission.ACCESS_FINE_LOCATION"
), there is no dialog shown and the permission is always denied. When I check with ActivityCompat.shouldShowRequestPermissionRationale
, it returns false, too. Indicating that the user either never was asked (what seams to be the problem here) or checked "never show again". The App Info displays "no permissions required".
My problem is related to this, but I already asked for permission as sugested in the answer.
Here is some of my code:
// firstly I call this function to check and request the permissions
private void checkPermissions(final String[] permissions) {
for(final String permission : permissions) {
if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(this, permission)) {
ActivityCompat.requestPermissions(this, new String[]{permission}, PERMISSION_REQUEST);
}
}
}
// This results in this callback to be called. No dialog is shown.
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSION_REQUEST: {
for (int i = 0; i < permissions.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
// The permmission is always denied ...
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[i])) {
// and we should not show a request. We always end up here
} else {
// here we should show the request again, but we dont end up here
}
}
}
}
}
}
I'm thankfull for any hint what I'm overlooking here.