Reputation: 27
I'm trying to use getLatitudeE6(); but eclipse shows me error:
The method getLatitudeE6() is undefined for the type Location
If I change to getLatitude(); without E6, it works fine and there is no error. but my target is to get accurate latitude and longitude in order to calculate an accurate distance between 2 points with distanceTo(); so I want to use getLatitudeE6
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double finishLati=location.getLatitudeE6() / 1E6;
double finishLongi=location.getLongitudeE6() / 1E6;
the distanceTo function:
Location locationA = new Location("A");
locationA.setLatitude(startLati);
locationA.setLongitude(startLongi);
Location locationB = new Location("B");
locationB.setLatitude(finishLati);
locationB.setLongitude(finishLongi);
double distance = locationA.distanceTo(locationB);
Upvotes: 0
Views: 68
Reputation: 73753
using getLatitudeE6()
vs getLatitude()
has nothing to do with you getting an accurate location. in fact you cant use getLatitudeE6 because it does not exist as you can see from the error you are getting when trying to use it.
the problem is that you are using getLastKnownLocation
which could be a location that is hours old or it could not even return you a location at all
Upvotes: 1