Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid AlarmManager Rescheduling Logic
    primarykey
    data
    text
    <p>I have an app which allows users to schedule alarms to sound at certain times, repeating at intervals of their choosing. I am using JSON to persist the alarm details, using SharedPreferences as storage.</p> <p>I am using AlarmManager to schedule when my app should be notified that an alarm should sound to notify the user. I am currently using the setRepeating() method of AlarmManager, supplying the interval provided by the user. This works well, and in theory the app would never need to update the JSon which stores the next alarm time, as AlarmManager will just reschedule the next alarm time using the interval.</p> <p>However, my thinking is that when the device is rebooted, I <em>will</em> need to supply a up to date alarm time to AlarmManager to avoid AlarmManager thinking an alarm has been missed as this is not necessarily the case.</p> <p>So, what's the best way to do this?</p> <ul> <li>update the JSon next alarm time when the alarm is sounded, even though this may not be necessary (setRepeating() handles this as long as there is no reboot)?</li> <li>register for and listen for shutdown broadcasts and update JSon then (this raises questions - just how long will the app get to calculate and write alarm details to storage given that the phone is shutting down)?</li> <li>don't update the JSon but add logic to the object which is <em>woken</em> by the AlarmManager to decide if the alarm just broadcast is valid and the user should be alerted?</li> </ul> <p>I'm sure any of the above will work, but I can't decide which is the nicest way to do it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload