Java.lang.stackoverflowerror When Request For Runtime Permission
Solution 1:
You have an infinite loop which I'm guessing is caused by someone denying Location permission, and selecting the "Never ask agan" checkbox:
This will automatically deny any further requests for the Location permission. In your case this becomes a big problem as PermissionManager::checkPermission()
prompts for the permission dialog using showDialogForPermission()
, which is automatically declined, which in turn calls onRequestPermissionsResult()
.
if (shouldShowRequestPermission(context, permission)) {
MY_REQUESTED_DIALOG = true;
showDialogForPermission(context, messageTitle, messageDetails, permission, requestCode);
} else {
/* THIS LINE IS STARTING THE INFINITE LOOP */
requestPermission(context, permission, requestCode);
}
Because shouldShowRequestPermission(context, permission)
is returning false
, MY_REQUESTED_DIALOG
is never set to true
and the process loops over and over. My advice would be to break out of the permission process if both shouldShowRequestPermission() == false
and your permission is declined in onRequestPermissionsResult()
.
if (shouldShowRequestPermission(context, permission)) {
MY_REQUESTED_DIALOG = true;
showDialogForPermission(context, messageTitle, messageDetails, permission, requestCode);
} else {
// Gracefully handle the fact that Location permission will never be granted
}
Solution 2:
That stacktrace is symptomatic of an infinite loop.
Post a Comment for "Java.lang.stackoverflowerror When Request For Runtime Permission"