What is a foreground feature? (compared to regular service)

Right now I have some class myService extends Service (), which is called using the startService function from a different context. The service runs some code in onStartCommand, and then is destroyed / killed.

What is a foreground service and how is it created? Does it last longer than other services?

If so, that would be ideal, because I was busy with a music player in my service, which I would like to play in the background and control. Now the problem is that my service is created and destroyed several times, so I launch too many instances of the music player and lose control of the original.

Thank.

+3
source share
1 answer

A foreground service is one that, for example, plays music - something that the user would immediately notice if he was killed. Android will support non-foreground killing services if system memory gets low, but it can kill the foreground service if necessary.

+3
source

All Articles