Can anyone help. I have built a service that executes with the BOOT_COMPLETED intent, hence my service is started when the device is booted.
n
In my onStartCommand i am registering the service with the AlarmManger to execute every 15 minutes.
This works but i notice that my service is never stopped hence when onStartCommand finished – it never stops, the onDestroy is NEVER called.
I need to return an integer from onStartCommand which i believe controls the life time..
What integer should i return?
What am i doing wrong?
Thank in advance
EDIT
Currently the serive returns super.onStartCommand(……
which is by default. So what is being returned here?
And if i remove it should i not call (rather than return) to super.onStartCommand on the first line on my onStartCommand in my class?
The SDK document of Service lifecycle say that
For the return value of
onStartCommand (Intent intent, int flags, int startId), the document says thatand
So, if you want to stop your service, you should call
Context.stopService()orService.stopSelf().