Foreground service: how to handle user enable/disable
<p>My Android application is a foreground service and I would like the option of the user being able to disable the service whenever they like, without having to uninstall the entire application.</p>

<p>I use the enabled = true label in the manifest and boot completed to start the service in the foreground. My concern is that should I have a very basic global boolean value (inside onCreate of the service) of userEnabled = false to prevent the service from starting (stopSelf), Android will continue to attempt to start my service which will result in a loop and therefore use unnecessary resource?</p>

<p>Please can someone share their knowledge with me to let me know that I either don't have to be concerned about this, or the correct procedure/method by which to do this? I can't find any documentation or posts that give direction. </p>

<p>I thank you in advance.</p>

<p>Answer: Please see CommonsWare's answer below and here is a link to some <a href="http://stackoverflow.com/a/5625179/1256219">useful code</a>, also by CommonsWare</p>

<p>After further reading, there is no loop that can be caused by having the service set enabled true in the Manifest.</p>
