I am facing a issue with getting current location in Android.
I am using FusedLocationAPI of android. But the latitude and longitude which I am getting is not accurate. I pasted that credentials on google maps, and it show's me place that is different from my accurate location.
I also tried to get location updates and verified the accuracy by Location.getAccuracy()
, here the the minimum accuracy which I gets is 10 meters.
Here I am using Fine Location as a permission.
So here my question is , how can I get my accurate location, In other words accuracy less then 5 meters.?
My Code is
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.enableAutoManage(this, this)
.build();
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setSmallestDisplacement(1);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,mLocationRequest,MainActivity.this);
@Override
public void onLocationChanged(Location location) {
Toast.makeText(MainActivity.this,";-"+location.getAccuracy(),Toast.LENGTH_LONG).show();
if(location.hasAccuracy() && location.getAccuracy()<lastLocationAccuracy){
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}