diff --git a/flutter_local_notifications/CHANGELOG.md b/flutter_local_notifications/CHANGELOG.md index 5e06399f8..f1bff846f 100644 --- a/flutter_local_notifications/CHANGELOG.md +++ b/flutter_local_notifications/CHANGELOG.md @@ -1,3 +1,7 @@ +# [17.0.2+1] + +* [Android] Use setWindow() for whileIdle alarm to. + # [17.0.2] * [Android] Remove old corrupted notifications. 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 edcacd6fd..71c37ec72 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 @@ -895,8 +895,17 @@ private static void setupAllowWhileIdleAlarm( checkCanScheduleExactAlarms(alarmManager); AlarmManagerCompat.setAlarmClock(alarmManager, epochMilli, pendingIntent, pendingIntent); } else { - AlarmManagerCompat.setAndAllowWhileIdle( - alarmManager, AlarmManager.RTC_WAKEUP, epochMilli, pendingIntent); + if (notificationDetails.inexactWindowLengthMillis > 0L + && VERSION.SDK_INT >= VERSION_CODES.KITKAT) { + alarmManager.setWindow( + AlarmManager.RTC_WAKEUP, + epochMilli, + notificationDetails.inexactWindowLengthMillis, + pendingIntent); + } else { + AlarmManagerCompat.setAndAllowWhileIdle( + alarmManager, AlarmManager.RTC_WAKEUP, epochMilli, pendingIntent); + } } } diff --git a/flutter_local_notifications/pubspec.yaml b/flutter_local_notifications/pubspec.yaml index e6ee281c9..6130aa51f 100644 --- a/flutter_local_notifications/pubspec.yaml +++ b/flutter_local_notifications/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_local_notifications_plus description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 17.0.2 +version: 17.0.2+1 homepage: https://github.com/Innim/flutter_local_notifications repository: https://github.com/Innim/flutter_local_notifications issue_tracker: https://github.com/Innim/flutter_local_notifications/issues