Reputation: 73753
I have a service that runs in the background that watches for location changes and then I plot the "route" on a map.
The problem is when I look at the route on the map it shows in locations where I was stopped for a period of time (a few minutes) that my location was jumping around that location and not stationary so the route looks bad.
Is there a way to stop this so that I have a nice continuous path?
I tried changing the minimum distance between location updates but that does not seem to do anything
locationManager = (LocationManager) this.getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locationManager.getBestProvider(criteria, true);
if(provider == null){
provider = LocationManager.NETWORK_PROVIDER;
}
locationManager.requestLocationUpdates(provider,25000,50, this);
Upvotes: 2
Views: 208
Reputation: 4179
The problem is not with your code but it's with the Satelite and GPS accuracy. It can't show you the exact location. So you need to make something like (if the location is changed below 5 meters don't notify me).
Update
Also you can use the location.getSpeed();
to get the speed the device is moving with so you can define if the location changed is reliable or not. If there is a little glitch in the Satelite or the GPS accuracy the device probably will move with 3480834 km/h or something like that.
Upvotes: 2