I’ve been seeing some strange issues using the Alarm manager in Android, despite the fact that I’m using RTC (non Wakeup) the phone will reliably send the PendingIntents on the correct repeating intervals.
Details of my test
- Device is not charging, just sitting on my nightstand while I slept
- My service woke up on its repeat interval (30 minutes, an extreme I know) EVERY TIME
- The service logged its activity in a file so I could read it in the morning
Now from my understanding the phone should be sleeping unless I wake it up and my Alarms should not be sent until the phone is awake.
- Why was my service executing?
- If another service is misbehaving and using the _WAKEUP variants of the alarm will my service wake up too?
- Can I avoid being woken by another service, and just awake from the user turning the screen on?
Presumably something else was having the device awake at those moments.
Yes, though “misbehaving” is in the eye of the beholder.
Not directly via
AlarmManager. You can watch forACTION_SCREEN_OFFandACTION_USER_PRESENTbroadcasts, and perhaps disable your alarms between those.