last modified: 22-feb-2017 (21:19)
When a Service is started,
onCreate method is invoked (if it is not running already) and subsequently
onStartCommand is called.
int value is returned which defines the restart behaviour of service. There are three values (ignoring
START_STICKY_COMPATIBILITY) for this purpose. I will discuss each of them briefly
START_STICKY service is killed by system, it restarts with following arguments
If there is any pending intent to be delivered, it is passed to
null is passed.
If service is killed before completing
onStartCommand, next time service if restarted with
flags = Service.START_FLAG_RETRY
In this case, service is only started if these is any pending intent to be delivered.
It is same as
START_STICKY with following differences
Service is restarted with last intent passed to service.
Service.START_FLAG_REDELIVERY if passed to