Starting services on Android Boot

by dapaintballer331 » Fri, 29 May 2009 02:30:33 GMT


Sponsored Links
 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?

I know how to get a service to start & communicate with a real
application, but I can't get it to start when the phone boots.

Thanks

--~--~---------~--~----~------------~-------~--~----~



Starting services on Android Boot

by HenrikH » Fri, 29 May 2009 03:35:12 GMT


 Add a BroadcastReceiver listening to BOOT_COMPLETED.

BR
/Henrik



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Starting services on Android Boot

by Mark Murphy » Fri, 29 May 2009 10:22:55 GMT


 > If I create a no-gui application that extends and android.app.Service

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!



--~--~---------~--~----~------------~-------~--~----~



Starting services on Android Boot

by aayush bhatnagar » Fri, 29 May 2009 10:31:11 GMT


 Hello Mark,
I am also designing an application which has similar uptime
requirements. It is a telephony client that needs to register with the
network on device bootup. After this, i listen for incoming requests,
or if the user decides to make a call, i initiate the same.
So, my application needs to stay alive for the entire duration the
device is up and running.

job for me too.

thanks
aayush





-- 
aayush
----------------------------------------------------
"Cleverly disguised as a responsible adult"

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Question about data transfer when browsing

Hello All,

I would like to know if there is any API or way to identify the amount
of KB transferred when perfoming Browser related options such as:

1. Browsing in a given website, launching webpages;
2. Downloading/Streaming a file;

After a given period, like 5 min, how many KBs were transferred during
this?

I really appreciate your help on that. Thanks in advance!

Best Regards,
Tiago Vidal

-- 

2. OpenGL gluUnProject

3. restore factory settings

4. licence apache 2.0

5. about /system/bin/playmp3

6. Need some help with the GUI

7. Runtime Exception before OnCreate()