title: Run a background task with android_alarm_manager in flutter
body: <p>I'm trying to use the <code>android_alarm_manager</code> plugin in <code>flutter</code> to run a simple background task periodicly. I followed the instructions from the <code>readme</code> file and it kind of worked but not properly..</p>
  <p>I sticked to the example and firstly created a periodicly task that prints a message every minute. After I run a hotstart for the app, I recived this message to the console:</p>
  <blockquote>
  <p>W/AlarmService( 4261): Attempted to start a duplicate background isolate. Returning...</p>
  </blockquote>
  <p>So I tried to cancel the task and create a new one that runs every 5 seconds. But that did not work out. Though the cancel method returns true, the first task is still running every minute and not every 5 seconds like intendet.</p>
  <blockquote>
  <p>Performing hot restart...</p>
  <p>Syncing files to device AOSP on IA Emulator...</p>
  <p>W/AlarmService( 4261): Attempted to start a duplicate background isolate. Returning...</p>
  <p>Restarted application in 2.194ms.</p>
  <p>I/AlarmService( 4261): AlarmService started!</p>
  <p>I/flutter ( 4261): [2020-07-24 06:21:34.697305] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:22:34.635681] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:23:52.208643] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:25:14.658737] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:26:14.703225] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:27:14.728071] Hello, world! isolate=531288143</p>
  <p>I/flutter ( 4261): [2020-07-24 06:28:14.760309] Hello, world! isolate=531288143</p>
  </blockquote>
  <p>This is the code I'm using. When I execute it the first time, I gave the id 0 to the task that runs every minute. So I tried to cancel this id and create a new one after initialize.</p>
  <pre><code>void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await AndroidAlarmManager.cancel(0);
      await AndroidAlarmManager.initialize();
      runApp(TimeReminder());
      await AndroidAlarmManager.periodic(const Duration(seconds: 5), 0, printHello);
  }
  
  void printHello() {
     final DateTime now = DateTime.now();
     final int isolateId = Isolate.current.hashCode;
     print(&quot;[$now] Hello, world! isolate=$isolateId&quot;);
  }
  </code></pre>
  <p>Does anyone know how to fix this? Or in general can anyone explain this to me? Is there a possibility to get an overview about all the tasks I have set?</p>
  <p>Thanks in advance!</p>