Reputation: 11205
I have an android application containing an Activity and a service. I want to make the service start at boot. I would use activity to just give a UI to the user to configure certain params and start the service. I want the service to start at boot time. I know that I can do it this way.
Now I have two questions related to this:
Upvotes: 0
Views: 74
Reputation: 10278
stopService will stop your service, assuming you called the correct service (if you have only 1, then it will work). And this is necessary for exactly your reason for asking, if params change you need to be able to start/stop the service.
Å new version update will automatically stop the service. After JB, the service will not automatically restart until the user opens your app, even on reboot. This is for security reasons.
Upvotes: 1
Reputation: 1725
Add a BroadcastReceiver
in your service, like you listening to the BOOT_COMPLETED
broadcast, then you can send a customized broadcast in your visual activity to make the service stop.
In this way you can also restart the service, just finish it and start a new one.
Upvotes: 0