Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>When the service gets called (Which after the first time you schedule a message, it is now running, all the time)</p> </blockquote> <p>Please do not waste the user's memory by having a service running that is not doing anything but watching the clock tick.</p> <blockquote> <p>it creates the alarm with the saved alarm time</p> </blockquote> <p>I am assuming, from context, that "creates the alarm" means "schedules an event with <code>AlarmManager</code>". If you are using <code>AlarmManager</code>, there is no reason to have a service that is "always running".</p> <blockquote> <p>I don't see a way to shut down that service from always running</p> </blockquote> <p>It should not have been "always running" in the first place. That being said, to stop a service, a service can call <code>stopSelf()</code>.</p> <blockquote> <p>So as soon as the service gets killed and restarted (like when the phone reboots), it launches, sees the alarm time is in the past, and immediately launches the service that sends the message</p> </blockquote> <p>Mark the message as having been sent in whatever persistent store that you are using for the rest of this.</p> <blockquote> <p>After the message sends the first time, i add 50 years (in milliseconds), to the alarm time, and resave it persistently. This way it won't trigger again until the user actually sets the time themselves. This seems to have worked, but IMO is a terrible solution.</p> </blockquote> <p>You are welcome to use a <code>hasBeenDelivered</code> <code>boolean</code> or the equivalent. Or, depending on your data structure, delete the entry entirely. Regardless, your persistent data model needs to reflect the sent/not-sent status of the message, however you choose to do it.</p>
 

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