title: Repeating Task in Foreground service in Doze mode
body: <p>I'm working on an application in which I have to do some repeating task at fixed interval (let's say after 2 mins) which should complete even in doze mode. My observations are mentioned below - </p>
  
  <ol>
  <li>Doing repeating task using Alarms (using RTC flag) aren't accurate. Android system batches alarms. If we use RTC_WAKEUP then it is better than RTC, but it shows WAKEUP count in Android Vitals which is not good.</li>
  <li>Jobschedulers are useful but will not work for lesser interval like 2 mins. I had tried Firebase Jobdispatcher but that is also not very accurate, I started Job with 2 mins Trigger time but it was varying from 10-20 mins.</li>
  <li>Used Handlers and Timers for repeating task in Foreground service. In this scenario Foreground service continue to run in Doze mode but handlers and timer stops repeating task. I read about Handlers.postDelayed() and found that this is also affected by doze mode.</li>
  </ol>
  
  <p>I don't want to acquire WAKELOCK for this repeating task.</p>
  
  <p>Can someone please suggest me some better/clean way by which we can do short interval repeating task in doze mode?</p>
  
  <p>For reference - </p>
  
  <p><a href="https://stackoverflow.com/questions/45886466/android-what-is-the-best-way-to-make-repetitive-background-tasks-android-oreo-r">Android: What is the best way to make repetitive Background Tasks Android Oreo ready?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/37869201/how-does-doze-mode-affect-background-foreground-services-with-without-partial-f/37869501#37869501">How does doze mode affect background/foreground services, with/without partial/full wakelocks?</a>  </p>