I want to grab the latitude and longitude of a phone without using a
mapview (I want to send the location to a server side process from a
form).... But this code constantly crashes the app :

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        LocationManager locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
        String provider = locationManager.getBestProvider(criteria,
true);
        Location loc = locationManager.getLastKnownLocation(provider);
        double lat = loc.getLatitude();
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to