Search code examples
androidandroid-servicebackground-serviceforeground-service

What is the difference between a background and foreground service?


I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are used.


Solution

  • Perhaps this will answer your question:

    A started service can use the startForeground API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. By default services are background, meaning that if the system needs to kill them to reclaim more memory (such as to display a large page in a web browser), they can be killed without too much harm.

    More info can be found here