I have to make sure that my Service will work until I explicitly call stopService() . so I have to return from onStartCommand() flag START_STICKY .
I also want that in case my Service is destroyed by the system, because low memory when the system recreates it, onStartCommand () will be called with the same intention, which initially launched the service in the first place. because this reason - I would like to use the flag START_FLAG_REDELIVERY . what I described may have happened (and actually happened to me) according to the documentation - http://developer.android.com/reference/android/app/Service.html#ProcessLifecycle
I know that I can start the service using startForground() , which prevents the service from being a candidate for destruction by the system when memory is low, but I prefer not to use this approach, and in any case, according to the documentation: the system can still kill it when extremely low pressure in memory.
so it would be ideal if I could return from onStartCommand() START_STICKY|START_FLAG_REDELIVERY
but according to the documentation it seems that you can use only one of the flags (maybe I'm wrong ??).
is it possible to somehow start a service that will work as I described?
source share