You should use a foreground service via the startForeground()
method if you are concerned about the possibility of the service being killed.
From the Service Lifecycle Docs:
- A started service can use the startForeground(int, Notification) 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. (It is still theoretically possible for the service to be killed under extreme memory pressure from the current foreground application, but in practice this should not be a concern.)