Android requestLocationUpdates with a 15 minute interval is causing gps indicator to fire constantly
this is the requestLocationUpdates call I am using, 900000 (15 minutes) and 500 meters shouldn't be causing the gps to fire constantly, its really draining battery...
I know this code isn't helpful.. But does anyone know why this might be happening?
in my onStartCommand
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 900000, 500, locationListener);
mLocation = mlocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
and then
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
mLocation = locati开发者_如何转开发on;
}
@Override
public void onProviderDisabled(String arg0) {}
@Override
public void onProviderEnabled(String arg0) {}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}
};
The time parameter to requestLocationUpdates()
is a hint, not a rule -- you may get locations more frequently than this.
If you want to stop consuming battery due to having the GPS on, call removeUpdates()
.
精彩评论