I am using a runtime permission request, but there is a problem with this. The onRequestPermissionsResult callback method onRequestPermissionsResult be called endlessly. Therefore, when the user rejects the request, the application does not respond.
a permission dialog appears every time the user clicks "deny". Only by clicking "never ask again" will he not appear again. * When you click "allow" it works well - no problem.
Is there a way to cancel a method that is called once?
if (ActivityCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED ) { ActivityCompat.requestPermissions( this, new String[]{ Manifest.permission.ACCESS_FINE_LOCATION }, LOCATION_PERMISSION_CUSTOM_REQUEST_CODE ); } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch( requestCode ) { case LOCATION_PERMISSION_CUSTOM_REQUEST_CODE: // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted MyManager.connect(); return; } else { // permission denied return; } default: return; } }
android permissions runtime
Bvtp
source share