We have a few repeating alarms setup and they work normally most of the time. Sometimes though they get stuck (probably canceled somehow). How to debug it to make sure an alarm is actually off when it seems stuck?
Regarding the reasons for the alarm to be cancelled: I'm aware it happens when the user force stops your app from Applications Manager. Can the system also randomly cancel it? (say when killing your whole app to reclaim resources?)
Handling the broadcast:Alarm service will invoke this receiver on scheduled time. Here we can trigger the local notification with the respective details(title, content, icon). The below code will help you to handle the broadcast. Now inside your onReceive() function, you need to initiate the notification.
IntentService + WakefulBroadcastReceiver + AlarmManager are deprecated with API 26 (Android 8.0 Oreo).
AlarmManager is a bridge between application and Android system alarm service. It can send a broadcast to your app (which can be completely terminated by user) at a scheduled time and your app can then perform any task accordingly.
Regarding debugging the alarms:
adb shell dumpsys alarm
I still haven't figured out if alarms can be killed other than by a force stop by the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With