How to keep a service running in background even after user quits the app?

Saurabh Agrawal picture Saurabh Agrawal · Feb 24, 2012 · Viewed 66.8k times · Source

I am developing an app where I start a service if a particular feature (in my app) is enabled by user. I want to keep running this service even after user quits my app. How can I do this? plz help

Answer

EGHDK picture EGHDK · Feb 24, 2012

Right from developer.android.com

A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it. A service is implemented as a subclass of Service and you can learn more about it in the Services developer guide.

So, as long as you create a service, and the user exits your app it will still run. Just like the example above.

This should give you all the information you need: https://developer.android.com/guide/components/services.html