Hi, all. I am developing an application for Android that gets the latitude and longitude of where the person is standing at a certain point in time.
I wrote a
test application. When I run the application, it appears to work fine, except the accuracy prints out 300 meters sometimes.
I go into Google Maps application and it has me within a few meters of my location on the map...It's pretty accuracte.
So my questions is, how is Google's coordinates so accurate when my application reports the reading being off by 300 meters?
Does Google massage the data some how to make it more accurate? Am I missing something in my code?
I need these readings to as accurate as possible. I also print the provider to the screen and it displays gps, so I believe I am not using the network (cell towers).
Here is how I am doing it.
First, I create a LocationManager : LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Then I get the provider using a Criteria Object:
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
String bestProvider = lm.getBestProvider(criteria, true);
Once I have the provider, I create my own location listener:
locationListener = new MyLocationListener();
private class MyLocationListener implements LocationListener {
public void onLocationChanged(Location loc) {
if (loc != null) {
Toast.makeText(getBaseContext(),
"Lat: " + loc.getLatitude() +
"\nLng: " + loc.getLongitude()+
"\nProvider: "+loc.getProvider()+
"\nAccuracy: "+loc.getAccuracy(),
Toast.LENGTH_SHORT).show();
}
}
....
}
Then I make a request for location updates:
lm.requestLocationUpdates(provider, 0, 0, locationListener, getMainLooper());
Any suggestions?
Thanks,
Chris