Gautam wrote: > 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,
Don't do that. > 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. Why not wake up every few hours and examine the CP for changes? > 2) if the service wants to maintain some cache that gets updated > periodically. You're going to waste RAM and battery life...to maintain a cache? > Any suggestion how to keep the service alive ALWAYS. You can't. Rewrite your code to assume the service will be stopped at some point. Since that will inevitably involve some sort of AlarmManager to wake up your service, you may as well take the next step and rewrite your code to just use the AlarmManager and let the service stop when there is no more work to be done. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---