0

I have made an alarm clock app that uses AlarmManager to place alarms. There is a broadcast receiver that receives the alarm broadcast, and then starts a foreground service.

Consider this situation: I do a fresh installation of my app on a device and add an alarm. I let a few seconds pass by, open a terminal window, and type the following command: adb shell dumpsys alarm. In the list, I can find the alarm registered by my app.

Now, I close the app (clear it from recents), make sure the alarm process is dead from Android Studio logcat, and again type the above command. I cannot find my alarm in the list! The alarm was there just a few seconds back, and now it is not there.

So I open the app again, delete this alarm, and add another alarm. With dumpsys, I can find my alarm in the list. I close my app and again execute dumpsys, only to find that this time, my alarm is there in the list. When the time arrives, the foreground service starts properly.

Why is the alarm getting cancelled after I close the app in case of a fresh installation?

Wrichik Basu
  • 1,005
  • 17
  • 28
  • I think it is expected behaviour..please refer below links. https://stackoverflow.com/questions/41392824/alarmmanager-pendingintent-gone-after-swiping-app-from-recent-apps-on-some-devi/41492023?noredirect=1 . https://github.com/evernote/android-job/issues/128 – Dilip Jul 30 '20 at 09:07
  • @Dilip that's irritating. Any workaround you know of? – Wrichik Basu Jul 30 '20 at 13:12

0 Answers0