I have a table with notification contents. One entry is always marked as isNext
, until none are left.
The days between the notifications vary and are also saved in said table, so I am using a "chain" of alarms, instead of one repeating alarm.
Now I read that all alarms of a manager will be reset after device reboot (does Alarm Manager persist even after reboot?).
Now it seems there are be two ways to solve this:
- Check every time if the alarm is set already and if not create it again, as asked here too: How to check if AlarmManager already has an alarm set?
- Or, as shown in the question above that, register a BroadcastReceiver with
<action android:name="android.intent.action.BOOT_COMPLETED" />
and just restart the alarm every time the device did a reboot
But both ways seem unreliable. Wouldn't that reset the alarm trigger time every single time? E.g. upon setting up the alarm it reads 3 days from the database, but then gets restarted and reads 3 again, so it gets pushed forward constantly.
Do I really have to do stuff like save current time distance in SharedPreferences
and then read it out every time or so?
What would be the optimal solution for my use case?