How to get coordinates of an address in android

Rahul Baradia picture Rahul Baradia · Mar 14, 2012 · Viewed 37.4k times · Source

How do i get gps co-ordinates of the location/address entered by user in android ?

Answer

Natali picture Natali · Mar 14, 2012
Geocoder geocoder = new Geocoder(<your context>);  
List<Address> addresses;
addresses = geocoder.getFromLocationName(<String address>, 1);
if(addresses.size() > 0) {
    double latitude= addresses.get(0).getLatitude();
    double longitude= addresses.get(0).getLongitude();
}