Ci-dessous est mon code, j'ai appelé ce code pour obtenir l'autorisation d'exécution. Dans ce cas, "shouldshowrequestpermissionrationale retourne toujours false". Je ne peux pas trouver une solution pourquoi c'est comme ça. Pour cette raison, l'alerte d'autorisation d'exécution n'est pas affichée. Proposez-moi une solution pls ...Autorisation d'exécution: shouldshowrequestpermissionrationale renvoie toujours la valeur false
private void checkRuntimePermission() {
Logger.infoLog("checkRuntimePermission");
if(ActivityCompat.checkSelfPermission(this, permissionsRequired[0]) != PackageManager.PERMISSION_GRANTED){
Logger.infoLog("checkRuntimePermission first if");
if(ActivityCompat.shouldShowRequestPermissionRationale(WelcomeActivity.this,permissionsRequired[0])){
Logger.infoLog("checkRuntimePermission if");
//just request the permission
//Show Information about why you need the permission
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Need Multiple Permissions");
builder.setMessage("This app needs Camera and Location permissions.");
builder.setPositiveButton("Grant", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
ActivityCompat.requestPermissions(WelcomeActivity.this,permissionsRequired,PERMISSION_CALLBACK_CONSTANT);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}else{
Logger.infoLog("Show request permission rationale false");
}
} else {
//You already have the permission, just go ahead.
Logger.infoLog("Permission given already");
proceedAfterPermission();
}
}