We have stumbled upon an issue in Android 8.1 and above that, we haven't seen before, and that, unfortunately, makes our app less convenient for our users. Background sticky services in Android 8.1 and above isn't re-started when user swipe kills the app.
In Android 8.0 and below, there are high promises for services to be always available in the background, especially for services that are implemented as "sticky services".
To sum it up, the non-sticky services is not re-launched during a swipe kill in the recent app list. For sticky services (application host together with the service), the app is re-launched shortly after the kill. And foreground services apps are actually never killed, even during a swipe kill.
This works as intended and just fine in Android 8.0 and before. So, after a kill swipe, the app process is re-created within a short time, and then onCreate and onStartCommand is called, starting up the service completely again.
But from Android 8.1, the onStartCommand call is omitted. So instead of getting onCreate and OnStartCommand, we get onCreate and OnDestroy. This effectively does not make the service active again. Needless to say, we cannot manually start our own service in onCreate either.
I think the following article shows the differences quite clear (and with functional code) between non-sticky services, sticky services, and foreground services.
In Android 8.1 and above, the onStartCommand call is omitted (and therefore the service is not restarted). So instead of getting onCreate and OnStartCommand, we get onCreate and OnDestroy during app re-creation.
Also, we would not prefer to have a visible app icon at the top persistent all the time (as when using setForeground service), and rather just let it work in the background without bothering the user too much.