Ich frage nach ACCESS_COARSE_LOCATION
Erlaubnis, aber kein Dialogfeld wird angezeigt.Anfrage-Permission-Dialog wird nicht angezeigt, wenn um Erlaubnis zu erteilen
Hier ist mein Code:
if (!checkPermissions()) {
requestPermissions();
} else {
getLastLocation();
}
hier requestPermission()
:
private void requestPermissions() {
boolean shouldProvideRationale =
ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_COARSE_LOCATION);
// Provide an additional rationale to the user. This would happen if the user denied the
// request previously, but didn't check the "Don't ask again" checkbox.
if (shouldProvideRationale) {
Log.i(TAG, "Displaying permission rationale to provide additional context.");
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
builder1.setMessage("Location permission is needed in order to show your current location");
builder1.setCancelable(true);
builder1.setPositiveButton(
"OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.RECORD_AUDIO},
PERMISSION_REQUEST_RECORD_AUDIO);
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
} else {
Log.i(TAG, "Requesting permission");
// Request permission. It's possible this can be auto answered if device policy
// sets the permission in a given state or the user denied the permission
// previously and checked "Never ask again".
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
REQUEST_PERMISSIONS_REQUEST_CODE);
}
}
Ich erhalte 08-31 13:02:25.067 8231-8231/com.appName.app/com.appName.app.MainActivity: Requesting permission
ausgedruckt, aber kein Dialog um Erlaubnis zu fragen zeigt nach oben.
Warum passiert das?