をありがとう、私はあなたが求めている正確に何か分からないが、あなたは、ユーザーが最初にshouldShowRequestPermissionRationale
を使用して場所の許可に反対するかどうかをテストすることができます。
以下は、私が使用している便利なドキュメントであるRequestion Permissionsに基づいた拡張コードです。
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "checkMyPermissions (" + permissionRequestCode + ") : Permissions FAILED");
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
// Show an explanation 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.
new AlertDialog.Builder(this)
.setMessage("In order to show data this app requires location permissions")
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
permissionRequestCode);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
permissionRequestCode);
}
return false;
} else {
Log.d(TAG, "checkMyPermissions (" + permissionRequestCode + ") : Permissions Passed");
return true;
}
あなたが何を求めているのか不明です。何があなたに再度ユーザーにプロンプトを表示できなくなるのを止めますか? –