Android Question gps best practices

3fazeac

Member
Licensed User
This question concerns the phone's GPS hardware remain on (and therefore draining the battery). I'm looking for advice for preventing this.
My app starts a service which starts the GPS. The intention is to have the service run for a long time occasionally using FTP to post the phone's co-ordinates to a server.

After a while the app is killed by the OS but the service continues (occasionally restarted using the StartServiceAt command).

When the GPS returns a location (myGPS_LocationChanged) the location is FTPed and then the GPS object is stopped. Some time later (on a timer) the GPS object is restarted, location co-ordinates are read and FTPed - then the GPS is stopped again.

This issue is that after a long time (often days) I find that the GPS status icon is permanently present in the phone's status bar. I restart the app (which presumably kills and restarts the service) and the GPS status icon reverts to its expected mode of appearing for a second or so and then disappearing - repeating this every minute or so depending on my timer parameters.

What is causing the GPS hardware to stay on? I assume the GPS object would be stopped and killed if the OS kills the service - so therefore the service must still be running. What would be the best way of ensuring that the GPS hardware is only on when it needs to be?
 
Top