But it doesn't work when the emulator is turned off and on again.
That is the correct behavior -- AlarmManager
's schedule is cleared on a reboot. You need to specifically register to receive the ACTION_BOOT_COMPLETED
broadcast, in order to re-establish your alarm events after a reboot.
I mean am I supposed to set the intent that the alarm manager does to the BroadcastReciever?
Well, if you are using a _WAKEUP
-style alarm, the recipe is to use a getBroadcast()
PendingIntent
with AlarmManager
, where the BroadcastReceiver
is either a WakefulBroadcastReceiver
(and follows those instructions) or passes control to my WakefulIntentService
.
I have somewhat-contrived examples of using WakefulIntentService
and WakefulBroadcastRecevier
.
How are the alarms stored in android?
AFAIK, they are held in the memory of a core OS process and are not persisted.