You need to use shouldShowRequestPermissionRationale as part of your conditional checks after checking permissions.
onResume is called so you can try the results of checking for this permission.
Here is an excerpt from what I have for the project I'm working on:
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (grantResults.length > 0) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission Granted pickDownloadFolder(); } else if (grantResults[0] == PackageManager.PERMISSION_DENIED) { // Permission Denied if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { result = "PERMISSION_DENIED"; Intent returnIntent = new Intent(); returnIntent.putExtra(resultKey, result); setResult(RESULT_CANCELED, returnIntent); finish(); } else { result = "PERMISSION_DENIED_FORCED"; Intent returnIntent = new Intent(); returnIntent.putExtra(resultKey, result); setResult(RESULT_CANCELED, returnIntent); finish(); } } } }
avluis
source share