Android Background service and process

时间:2016-09-01 06:19:19

标签: android cordova

I am developing a hybrid application. I had used a plugin for track the location continuously using background service.

My problem is if I didn't use my application 2 days. The process is getting killed by itself. The status is changed to 0 process 1 service running. So cannot get location updates.

So how to resolve my issue? The below link is my location tracking plugin code for cordova.

https://github.com/selfservit/Track-Device-Location

1 个答案:

答案 0 :(得分:0)

Android只要需要清除内存就会终止服务。您可以在服务中使用START_STICKY,但这并不能100%确保您的服务在被杀后再次启动。我建议使用AlarmManager检查服务是否正在运行,如果不是,请重新启动该服务。