In API >= 23, we are required to ask users for permission at run-time. But for some reason, the permissions are causing onResume to be called infinitely. What causes this?
@Override
protected void onResume() {
super.onResume();
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.ANYPERMISSION},1);
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
}
When you show dialog of permission question, Acitvity goes to onPause
, and when dialog hides, it goes to onResume
. You have to change place of asking of permission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With