From android.com it says that a foreground service is something that the user is aware of and a foreground service is unlikely to be killed if memory is needed. It says a background service may be killed if memory is needed. Is this the only difference or can one service offer extra features?
My main question is, why would a background service be used if it is likely to be killed. Can anyone provide an example of an app would use a background service?
Is this the only difference or can one service offer extra features?
To have a foreground service, you have to show a
Notification in the status bar. Ideally, that
Notification gives the user the ability to control the operation of the app, such as to stop whatever the foreground service is doing (e.g., playing music).
why would a background service be used if it is likely to be killed
Among other reasons, users get very cranky if you add icons to their status bar without a good justification for having them there.
In general, you use neither type of service, unless it is actively delivering value to the user. Many background services are short-lived, doing a particular bit of work (e.g., checking a mail server for new messages) and going away. There is no strong reason to have a foreground service for that work, though a few developers will do that anyway.
Can anyone provide an example of an app would use a background service?
Most of the apps on your device use background services.