[android-developers] I don't see how to do this....
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();
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home