Self Terminating a Service

Once your Service has completed the actions or processing it was started for, you should make a call to stopSelf, either without a parameter to force a stop, or by passing in a startId value to insure processing has been completed for each instance of startService called so far, as shown in the following snippet:

stopSelf(startld);

By explicitly stopping the Service when your processing is complete, you allow the system to recover the resources otherwise required to keep it running. Due to the high priority of Services they are not commonly killed by the run time, so self-termination can significantly improve the resource footprint of your application.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment