Hi,

   Though it is recommended to run the service as required and stop
after it is done, I'm planning to keep my service active always,
because
1) I want to listen to some system CP change and update my own DB. So,
need to register Content Observer and act appropriately. Plan to
register the observers after receiving boot completed.
2) if the service wants to  maintain some cache that gets updated
periodically.

  I started the service in  onReceive() after receiving boot completed
and spwaned a worker thread (that is a looper and wait for messages to
process). I set setForeground(true) for the service. The service
process starts and the thread starts. But I could see from system log
that the process gets killed.

  I don't want this to happen. What I want is that the process would
remain and next time when I start an activity or a receiver that
requires service, they should use the already created service.

  Any suggestion how to keep the service alive ALWAYS.
  btw, when I start the service from an activity and setForeground
(true), then i could see that the oom_adj parameter for the process is
getting set to 2, instead of 0 or 1.

Thanks.



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

Reply via email to