I’m making an Android app and need to use GPS for recording a drivers statistics such as Speed, heading, altitude and long/lat with a good accuracy.
I need to track the location every second but i don’t seem to be getting accurate results. I’ve tried an Android GPS app on the market and that returns correct results.
So far I have this.
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
Location location = locationManager.getLastKnownLocation(provider);
VehicleListener vl = new VehicleListener();
locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, vl);
if (location != null) {
System.out.println("Provider " + provider + " has been selected.");
lat =location.getLatitude();
lon = location.getLongitude();
}
You are using a empty Criteria. If you desire more accuracy try with this: