I am creating a tracking system for vehicles that get location from the Google Play Services location API. I set the update interval to 5 seconds, which gives good results when driving. To avoid getting updates next to each other, for example, when the vehicle is stopped at a traffic light, I set setSmallestDisplacement (int meters) to 50 meters. My understanding of this would be that I should receive updates every 5 seconds if the location has not changed less than 50 m. But it doesnβt look like I still get them almost every 5 seconds with places just a few meters away (this is due to the normal GPS drift).
The question is, did the setSmallestDisplacement () effect get it wrong, or does it not work as it should?
Relevant Code:
private LocationRequest request; private LocationClient client; request = LocationRequest.create(); request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); request.setInterval(5000); request.setFastestInterval(1000); request.setSmallestDisplacement(50); client = new LocationClient(this, this, this); if (servicesConnected()) client.connect(); @Override public void onConnected(Bundle dataBundle) { try { gpsConnected = true; client.requestLocationUpdates(request, this); Log.i(TAG, "Connected to Google Play Services"); } catch (Exception e) { Log.e(TAG, "onConnected", e); } }
Jouse source share