以下は私のコードですが、私はこのコードを実行時アクセス許可を得るために呼び出しました。この場合、 "shouldshowrequestpermissionrationaleは常にfalseを返す"。私はなぜそれがこのようなgoindな解決策を見つけることができません。このため、実行時アクセス許可アラートは表示されません。私に解決策を教えてください...実行時アクセス許可:shouldshowrequestpermissionrationaleは常に偽を返します
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();
}
}