tags:

views:

85

answers:

2

At Android application, it always extends Activity and the entry is onCreate. So it seems that user has to select application and click to luanch it.(if it is wrong,please advise me. sorry)

So, how to implent a service running on background without user clicking to start application?

+2  A: 

Use an IntentReceiver to receive the BOOT_COMPLETED_ACTION.

Then in the IntentReceiver, you can call startService().

yuku
Please do not write everlasting services: http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/ http://www.androidguys.com/2010/03/29/code-pollution-background-control/
CommonsWare
+1  A: 

And when I install the applications apk on the emulator/device then the service will start running

That is not possible. Android does not allow applications of any form to run immediately upon installation.

CommonsWare