title: How to keep app going on lock screen in Flutter?
body: <p>So i've created an app that plays sounds after intervals - for my cycling and running routines.</p>
  
  <p>But when i lock the screen of my android phone the app stops working after about 15 seconds. </p>
  
  <p>The app's code look like so:</p>
  
  <pre><code>DateTime duration = new DateTime.fromMicrosecondsSinceEpoch(interval.inMicroseconds);
  Timer counterSeconds;
  Icon iconTimerStarter = new Icon(iconStart);
  DateFormat minutesSeconds = new DateFormat("ms");
  static AudioCache player = new AudioCache();
  
  void startTimer(interval) {
    if (duration.millisecondsSinceEpoch == 0) {
      duration = new DateTime.fromMicrosecondsSinceEpoch(interval.inMicroseconds);
    }
    counterSeconds = new Timer.periodic(oneSec, (Timer t) =&gt; handleTick());
    _setIconForButton(new Icon(iconCancel));
  }
  
  void handleTick() {
    print(duration);
    setState(() {
      duration = duration.subtract(oneSec);
      if (duration.millisecondsSinceEpoch == 0) {
        stopTimer();
        if(sprint){
          player.play(alarmWalk);
          startTimer(Duration(seconds: 90));
        }else{
          startTimer(Duration(seconds: 30));
          player.play(alarmSprint);
        }
        sprint = !sprint;
      }
    });
  }
  </code></pre>
  
  <p>The packages i use:</p>
  
  <pre><code>import 'package:audioplayers/audio_cache.dart';
  import 'package:flutter/material.dart';
  import 'package:intl/intl.dart';
  </code></pre>
  
  <p>I want the app to keep counting and playing sounds while the screen on my phone is locked. (it works fine when minimized but when the screen is locked it just freezes after like 15 seconds).</p>