tree: a2f36c357410dbf106e01caa6f8c41bcc004bab8 [path history] [tgz]
  1. android/
  2. example/
  3. ios/
  4. lib/
  5. .gitignore
  6. .gitkeep
  7. android_alarm_manager.iml
  8. android_alarm_manager_android.iml
  9. CHANGELOG.md
  10. LICENSE
  11. pubspec.yaml
  12. README.md
packages/android_alarm_manager/README.md

android_alarm_manager

A Flutter plugin for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire.

Getting Started

After importing this plugin to your project as usual, add the following to your AndroidManifest.xml:

<service
    android:name="io.flutter.androidalarmmanager.AlarmService"
    android:exported="false"
    android:process=":remote"/>

Then in Dart code add:

import 'package:android_alarm_manager/android_alarm_manager.dart';

void printHello() {
  final DateTime now = new DateTime.now();
  final int isolateId = Isolate.current.hashCode;
  print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}

main() async {
  final int helloAlarmID = 0;
  runApp(...);
  await AndroidAlarmManager.periodic(const Duration(minutes: 1), helloAlarmID, printHello);
}

printHello will then run (roughly) every minute, even if the main app ends.

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.