Reputation: 4448
I am using a LocationClient
for retrieving the current user location, and i'm trying to create a LocationRequest
with a distance value as well as the update interval.
My code currently requests location updates by update interval:
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(updateInterval);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
if (mLocationClient.isConnected()) {
mLocationClient.requestLocationUpdates(mLocationRequest, this);
}
In the LocationManager
there is a method to request location updates by distance
public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)
Upvotes: 4
Views: 1815
Reputation: 38856
You can use setSmallestDisplacement to set the smallest distance traveled between updates in meters. Just add this to your code.
mLocationRequest.setSmallestDisplacement(SMALLEST_DISPLACEMENT);
Upvotes: 6