[Bug]: permissions is already running
Please select affected platform(s)
- [x] Android
- [ ] iOS
- [ ] Windows
Steps to reproduce
1.start to get the permission like camera. 2.cancle the permission dialog by gesture.(onrequestpermissionResult will not callback on this moment) 3.start to get the camera permission again. 4.bug happened.
Expected results
I tried to fix this, but I'm not sure if it will affect the others。
My modification plan like it↓:
private boolean isAbleToClearCount = false;
@PermissionConstants.PermissionStatus
private int determinePermissionStatus(final @PermissionConstants.PermissionGroup int permission) {
if (isAbleToClearCount) {
isAbleToClearCount = false;
pendingRequestCount = 0;
}
line 435:
if (permissionsToRequest.size() > 0) {
isAbleToClearCount = true;
final String[] requestPermissions = permissionsToRequest.toArray(new String[0]);
ActivityCompat.requestPermissions(
activity,
requestPermissions,
PermissionConstants.PERMISSION_CODE);
}
Looking forward to your reply。
same
I encounter the same issue.
Reproduce steps:
- request a permission
- use Android gesture to switch to home screen
- click the app icon to resume app
The permission dialog will disappear and saw this warning in logcat.
onRequestPermissionsResult is called without results. This is probably caused by interfering request codes. If you see this error, please file an issue in flutter-permission-handler, including a list of plugins used by this application: https://github.com/Baseflow/flutter-permission-handler/issues
I try this modification and the problem solved.
@Override
public boolean onRequestPermissionsResult(
int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
...
if (permissions.length == 0 && grantResults.length == 0) {
Log.w(PermissionConstants.LOG_TAG, "onRequestPermissionsResult is called without results. This is probably caused by interfering request codes. If you see this error, please file an issue in flutter-permission-handler, including a list of plugins used by this application: https://github.com/Baseflow/flutter-permission-handler/issues");
pendingRequestCount = 0; // <------ ADD THIS
return false;
}
...
Just found the permission_handler_android v13.0.1 fixed the issue with the same solution.