Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/android_alarm_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 24 additions & 3 deletions packages/android_alarm_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/).

Expand Down
5 changes: 2 additions & 3 deletions packages/android_alarm_manager/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/android_alarm_manager

Expand All @@ -22,5 +22,4 @@ flutter:

environment:
sdk: ">=2.0.0-dev.28.0 <3.0.0"
# TODO(bkonyi): set minimum Flutter version to next stable release
flutter: ">=1.2.0 <2.0.0"
flutter: ">=1.9.1 <2.0.0"