How to keep my requestlocationupdates alive

84 views Asked by At

I'm sending my coordinates to my server every 10meters so i can track myself.

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, time, meters, locationListener);

this works fine i get my coordinates. However i'm worried that after a while the phone will shutdown the app and my locationListener will stop? Is there a way to ensure that my app will keep listening for locationupdates?

1

There are 1 answers

1
Carnal On BEST ANSWER

Create a Service to keep track of your locationchanges, and in onStartCommand you can return START_STICKY to keep the Service alive until you stop it.

Example: http://developer.android.com/reference/android/app/Service.html#LocalServiceSample