Hello,

I'm working in an application which requires to have accurate longitude,
latitude and altitude.
Using Android Location Service, I think latitude and longitude are quite
accurate, but I'm not sure about altitude.

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 3; // 3 meters
private static final long MIN_TIME_BW_UPDATES = 1000; // 1 seconds
private LocationManager locationManager;
private double longitude;
    private double latitude;
    private double altitude = 0;

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        locationManager = (LocationManager)
getSystemService(LOCATION_SERVICE);
        locationManager.requestLocationUpdates(getProvider(),
MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

        updateLocation(locationManager.getLastKnownLocation(getProvider()));


     }


 private Criteria getCriteria() {
        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(true);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);

        return criteria;
    }

    private String getProvider() {
        return locationManager.getBestProvider(getCriteria(), true);
    }

 private void updateLocation(Location location) {

        longitude = location.getLongitude();
        latitude = location.getLatitude();
        altitude = location.getAltitude();
        timeTaken = location.getTime();

        tvCurrentLocation.setText("Alt: " + altitude + "\n" +
                "Lon: " + longitude + "\n" +
                "Lat: " + latitude + "\n" +
                "Time: " + new Date(timeTaken).toLocaleString());
    }

is there any alternative way to get accurate altitude.

Any help is much appreciated.

Thanks.

------------
Sincerely
A. N. M. Bazlur Rahman
Software Engineer
Therap Services, LLC

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to