From c901b4f9e1e3070b4dc762940e6e3fedaf5c4e85 Mon Sep 17 00:00:00 2001 From: Tiernan Date: Sat, 3 Sep 2022 21:15:53 +1000 Subject: [PATCH] Check permissionRequestInProgress in onRequestPermissionsResult (#1686) Other flutter plugins permissions requests can end up triggering onRequestPermissionsResult, so only handle callbacks when we're expecting one to be outstanding. This fixes a `java.lang.IllegalStateException: Reply already submitted` crash. --- .../FlutterLocalNotificationsPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index e1f99e455..d7d0bc0ec 100644 --- a/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/flutter_local_notifications/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -1574,7 +1574,7 @@ public void requestPermission(@NonNull PermissionRequestListener callback) { @Override public boolean onRequestPermissionsResult( int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) { + if (permissionRequestInProgress && requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) { boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; callback.complete(granted);