Android examples for Map:Address
get Address from latitude longitude
import java.io.IOException; import java.util.List; import java.util.Locale; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class Main{ //from w w w .j a v a 2 s . com private Context mContext; private double mLat; private double mLng; public String getAddress() { return LocationHelper.getAddress(mContext, mLat, mLng); } public static String getAddress(Context context, double lat, double lng) { String addressString = "No address found"; Geocoder gc = new Geocoder(context, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); if (addresses.size() > 0) { Address address = addresses.get(0); addressString = address.getAddressLine(0); addressString = addressString.substring(addressString .indexOf(" ") + 1); } } catch (IOException e) { e.printStackTrace(); } return addressString; } }