On Thu, Jun 17, 2010 at 1:03 PM, Mike Wolfson <mwolf...@gmail.com> wrote:
> This is the gist of my problem.  I currently use my Broadcast Receiver
> to start a service (that remains running) - and the service registers
> my Alarms.  I may be confusing things, but I am thinking if my service
> is stopped, the alarms are no longer maintained by the system.

Well, if the service is nuked from orbit via a task killer, alarms
definitely go away.

If the service is stopped conventionally (e.g., stopService(),
stopSelf()), alarms definitely stay. You can see this with the
WakefulIntentService demo code -- IntentService calls stopSelf() when
there is no more work to do.

I am uncertain what happens if Android decides to stop the service due
to insufficient memory, because I have no idea how to reproduce that
situation.

> If you are registering alarms in a service, a) the service must remain
> running in order for them to remain registered

This is absolutely positively not true. See the WakefulIntentService demo code.

> I wonder if this is also what Onomp was trying to say about
> registering them in the Broadcast Receiver.  That after the
> BroadcastReceiver is no longer running, the alarms are no longer
> registered.

This too is absolutely positively not true. See the
WakefulIntentService demo code. Manifest-registered BroadcastReceivers
are "no longer running" as soon as onReceive() ends.

> (if the service is killed by a Task Killer, or by the system due to
> memory constraints)
> -In the service onDestroy() method, cancel the alarms, and trigger the
> BroadcastReceiver (which will recursively call the Service, and re-
> register the Alarms).

If the service is killed by a task killer, your process is terminated,
and you do not get control in onDestroy().

The process may also be terminated as part of the emergency memory
reclamation efforts of the OS.

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to android-disc...@googlegroups.com.
To unsubscribe from this group, send email to 
android-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en.

Reply via email to