Tuesday, December 11, 2012

Re: [android-developers] How to start service at boot time?

On Tue, Dec 11, 2012 at 9:14 AM, Bajrang Asthana
<asthana.bajrang@gmail.com> wrote:
> I want to know how to start service at boot time?

Register a BroadcastReceiver in the manifest for
ACTION_BOOT_COMPLETED, and have the receiver start the service.

Having an always-running service is an anti-pattern in Android,

> I am wondering how do
> apps like Easy Battery Saver or Open Advanced Task Killer work?

Note that apps like Advanced Task Killer are designed to help users
defend themselves against developers who try to have an always-running
service.

> Is starting service at boot time possible in Android 3.1+

Yes, though you will also need an activity on Android 3.1+, and the
user must manually launch that activity before your boot-time
BroadcastReceiver will get control.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.4 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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment