0

The app that I'm writing uses the GPS location manager service requestLocationUpdates() but I would like to be able to change the min Time and min Distance parameters throughout the program. I initialize the location listener on creation but I can't figure out how to change these parameters or even find out if it's possible to do that. The main purpose for this would be to conserve battery life when the program doesn't need regular position updates. Thanks so much for your help! -Dom

skaffman
  • 398,947
  • 96
  • 818
  • 769
GPSmaster
  • 844
  • 3
  • 15
  • 31

2 Answers2

5

I'm not sure if this is correct, but faced with the same problem, I occasionally remove the LocationListener and then later add it back with a different refresh interval:

if (locationManager != null && locationListener != null) {
    locationManager.removeUpdates(locationListener);
}

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, refreshInterval, 50, locationListener);
Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
Judah Sali
  • 1,088
  • 1
  • 7
  • 12
  • 2
    Thanks so much! This works great and I'm using this method in my app now. Sorry it took me so long to reply. In the excitement of the moment I must have forgot to thank you. – GPSmaster Apr 07 '11 at 18:26
0

Unfortunately the requestLocationUpdates() method keeps the gps on until removeUpdates() is called. In the end I used a timer to request a location and immediately removeUpdates() every minute (to conserve battery).

GPSmaster
  • 844
  • 3
  • 15
  • 31