I have a service that tracks the user locations. It doesn't have to run 24x7 but it should run for the duration of the trip. Following are the things that I have implemented till now to ensure it's continuous functioning :
- started service as foreground
- used "START_STICKY"
- started an alarm which checks every 10 mins if service is running. If not it starts service.
Despite of all these measures, for some devices(like MI 3w) service gets killed within 10 mins and doesn't restart at all(not even after waiting for 12 hours!). From extensive googling I have learned that when process is killed by OS the alarm doesn't trigger(correct me if I am wrong), so this might be the case here. But what happened to "START_STICKY"?
So my queries are :
- What happened to START_STICKY? Is it an OS bug (OS V6)?
- Why does OS cancel all the set alarm while killing the process?
- Most importantly how to ensure that my service runs for the trip duration?