> If I create a no-gui application that extends and android.app.Service > class, how do I get it to register itself so that the application > starts when the phone boots up? > > I need some way to have it always launch when the phone is turned on, > how can I do this?
To repost my answer to a very similar question: First, make sure this is really the architecture you want. Odds are, it's not -- details later in this message. To get control at boot time, you need to hold the RECEIVE_BOOT_COMPLETED permission and register a BroadcastReceiver in your manifest that watches for the BOOT_COMPLETED broadcast Intent. Then, you have five seconds to do something. My strong recommendation is that you use AlarmManager to schedule yourself to run like a cron job, so your code can execute every so often to do something useful. You could start a service directly instead. However, your service will shortly thereafter stop running, because the device will go to sleep. And, if you decide you'll hold a WakeLock and force the device to stay awake forever and ever and ever, you'll drain the battery in no time flat. So, you may as well design your app to only run so often, and then you can use AlarmManager and be friendlier to your users. -- Mark Murphy (a Commons Guy) http://commonsware.com _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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

