Thursday, 2 June 2016

Get Location by lat,Long Android


public String GetAddress(double latitude, double longitude) {

    Geocoder geocoder = new Geocoder(this, Locale.getDefault());
    String city = "", state = "", address = "";
    try {
        List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
        address = addresses.get(0).getAddressLine(0) + " " +
      addresses.get(0).getAddressLine(1);
        city = addresses.get(0).getLocality();
        state = addresses.get(0).getAdminArea();
        String zip = addresses.get(0).getPostalCode();
        String country = addresses.get(0).getCountryName();
    } catch (Exception e) {

    }
    return city;
}

No comments:

Post a Comment