2

I'm adding alarms via AlarmManager.

Checking with this command if the alarm exist: adb shell dumpsys alarm

After setting the alarm (repeating alarm setRepeating()), if I close the app via back button or close via task manager, the alarm is still there in the log.

But when I re-run the app (shift f10) from Android studio the alarm is not there anymore!

What am I missing?

Pavel Poley
  • 5,307
  • 4
  • 35
  • 66

2 Answers2

0

When you re-run the app the Android studio installs the app, so you'll lose the Alarm.

The repeat alarm cancels when cancel(OnAlarmListener) is called which I guess happens when updating/re-install the app.

You may find this StackOverflow's answer useful.

Consider other ways to apply the app changes as an alternative.

  • but when I install it the second time from the android studio the time alarm is active if I check from pending intent. but the alarm is not triggered. – tej shah Jul 26 '23 at 06:24
0

When you re-run you app with Shift+F10 means that Andriod Studio make "Force Stop" for your application. If your application is force stopped then you application will never receive any of alarms because process of your application is not placed inside memory of phone. No process = no alarms. It's awful but it is reality :(

hi.cosmonaut
  • 120
  • 1
  • 9