From 934550a80598fb2c96432b10c450705bac36bb34 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Tue, 3 Dec 2019 15:55:22 -0800 Subject: [PATCH] [ android_alarm_manager ] Loosen Flutter SDK lower bound, update README --- packages/android_alarm_manager/CHANGELOG.md | 6 +++++ packages/android_alarm_manager/README.md | 27 ++++++++++++++++++--- packages/android_alarm_manager/pubspec.yaml | 4 +-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/packages/android_alarm_manager/CHANGELOG.md b/packages/android_alarm_manager/CHANGELOG.md index 055086daf6d2..f8927f093f9e 100644 --- a/packages/android_alarm_manager/CHANGELOG.md +++ b/packages/android_alarm_manager/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.4.5+1 + +* Loosen Flutter version restriction to 1.9.1. **NOTE: plugin registration + for the background isolate will not work correctly for applications using the + V2 Flutter Android embedding for Flutter versions lower than 1.12.** + ## 0.4.5 * Add support for Flutter Android embedding V2 diff --git a/packages/android_alarm_manager/README.md b/packages/android_alarm_manager/README.md index 33a98b71aab1..a48098867865 100644 --- a/packages/android_alarm_manager/README.md +++ b/packages/android_alarm_manager/README.md @@ -59,11 +59,21 @@ will not run in the same isolate as the main application. Unlike threads, isolat memory and communication between isolates must be done via message passing (see more documentation on isolates [here](https://api.dart.dev/stable/2.0.0/dart-isolate/dart-isolate-library.html)). + +## Using other plugins in alarm callbacks + If alarm callbacks will need access to other Flutter plugins, including the -alarm manager plugin itself, it is necessary to teach the background service how -to initialize plugins. This is done by giving the `AlarmService` a callback to call -in the application's `onCreate` method. See the example's +alarm manager plugin itself, it may be necessary to inform the background service how +to initialize plugins depending on which Flutter Android embedding the application is +using. + +### Flutter Android Embedding V1 + +For the Flutter Android Embedding V1, the background service must be provided a +callback to register plugins with the background isolate. This is done by giving +the `AlarmService` a callback to call the application's `onCreate` method. See the example's [Application overrides](https://github.com/flutter/plugins/blob/master/packages/android_alarm_manager/example/android/app/src/main/java/io/flutter/plugins/androidalarmmanagerexample/Application.java). + In particular, its `Application` class is as follows: ```java @@ -92,6 +102,17 @@ Which must be reflected in the application's `AndroidManifest.xml`. E.g.: **Note:** Not calling `AlarmService.setPluginRegistrant` will result in an exception being thrown when an alarm eventually fires. +### Flutter Android Embedding V2 (Flutter Version >= 1.12) + +For the Flutter Android Embedding V2, plugins are registered with the background +isolate via reflection so `AlarmService.setPluginRegistrant` does not need to be +called. + +**NOTE: this plugin is not completely compatible with the V2 embedding on +Flutter versions < 1.12 as the background isolate will not automatically +register plugins. This can be resolved by running `flutter upgrade` to upgrade +to the latest Flutter version.** + For help getting started with Flutter, view our online [documentation](http://flutter.io/). diff --git a/packages/android_alarm_manager/pubspec.yaml b/packages/android_alarm_manager/pubspec.yaml index 55e1605c144d..d72d4da1d3c5 100644 --- a/packages/android_alarm_manager/pubspec.yaml +++ b/packages/android_alarm_manager/pubspec.yaml @@ -1,7 +1,7 @@ name: android_alarm_manager description: Flutter plugin for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire. -version: 0.4.5 +version: 0.4.5+1 author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/android_alarm_manager @@ -22,4 +22,4 @@ flutter: environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" - flutter: ">=1.12.0 <2.0.0" + flutter: ">=1.9.1 <2.0.0"