0

This Doze mode makes it quite hard for me to implement proper alarms system. Basically I want to allow my user to run a webservice call each 15 or 30 minutes for instance. So let's say the user sets the app to run the alarm each 30 minutes. While the device is normal use, the alarms will fire more or less exact (I'm using setRepeating) but it's good enough for my purpose.

When the device is dozing, as per docs, my repeating alarms do not fire, BUT when the device exits doze mode, all the alarms that did not run, run one after another(or similar). So I end up in the morning with maybe 4-6 alarms fired one after another, all fetching the same data from the webservice. Or same thing when a maintenance window occurs...

Is there a way to tell the doze mode that if my alarm did not fire at required time, to not run it at all? Or if there are multiple alarms that did not fire, only fire the last one?

LE: I had an error in code which ran the alarm too often, that is why I had the impression that postponed alarms will all run one after another...

Alin
  • 14,809
  • 40
  • 129
  • 218
  • You can use `setAndAllowWhileIdle()` to run alarm directly in doze mode – Vüsal Feb 21 '17 at 08:58
  • @Vusal `setAndAllowWhileIdle()` does run while dozing but does not allow network access, so it's useless. Thank you for your time – Alin Feb 21 '17 at 09:47

0 Answers0