From my little android knowledge I understand that android OS can kill my service under extreme memory conditions.
I have created a service that returns START_STICKY. The service is meant to run in background.
If android is about to kill my service, will it call onDestroy ?
And when it restarts it would it call onCreate ?
See here, the dev guide. http://developer.android.com/reference/android/app/Service.html#ProcessLifecycle
onCreate()is only called when the process starts, which can either be the first time the service is running, or if it was killed on restarted, essentially this is called whenever it starts.onStartCommand()is called whenever a client callsstartService().When a service is destroyed / completely stopped, Android is supposed to call
onDestroy()on that service. I think it’s possible for that to not happen (e.g. process is killed not through Android system). In the case of a bound service, this is when there are not more active client binders.Edit:
onCreate()Service starts;onStartCommand()someone uses service;onDestroy()Service is killed / stopped.