Android : Why Location client gives very far from my current location.?

on Wednesday, July 30, 2014


I am developing a location based app which have the functionality to update user current location in every 1 minutes.


I am using bellow to code for requesting location updates:



private LocationRequest mLocationRequest;
private static LocationClient mLocationClient;

mLocationRequest = LocationRequest.create();

mLocationRequest.setInterval(60000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setFastestInterval(60000);

mLocationClient = new LocationClient(this, this, this);

if (servicesConnected()) {
mLocationClient.connect();
}


servicesConnected() is user defined method which returns true if Google play services is available otherwise returns false and my overriden method like this:



@Override
public void onConnected(Bundle connectionHint) {
try {
mLocationClient.requestLocationUpdates(mLocationRequest, this);
} catch (IllegalStateException e) {
// TODO: handle exception
}
}

@Override
public void onLocationChanged(Location location) {
// logic to store location data

}


But I found location updates like bellow figure while my GPS is ON :


enter image description here


Please suggest what should I do to overcome unwanted location updates.


0 comments:

Post a Comment