Code example for Geocoder

Methods: getFromLocation

0
  final static String Tag = LocationTool.class.toString();
 
  public static String getLocality (GeoPoint p, Context ctx) {
    String location = "";
    try { 
      Geocoder geocoder = new Geocoder(ctx, Locale.getDefault());
      List<Address> addresses = geocoder.getFromLocation(p.getLatitudeE6() * 1e-6, p.getLongitudeE6() * 1e-6, 1);
      Address address = (addresses != null && addresses.size() > 0) ? addresses.get(0) : null;
      StringBuffer result = new StringBuffer();
      if (address != null) {
        /** 
        result.append(address.getThoroughfare() != null ? address.getThoroughfare() : ""); 
        result.append(", "); 
        **/ 
        result.append(address.getLocality() != null ? address.getLocality() : "");
        result.append(", ");
        result.append(address.getAdminArea());
        result.append(" " + address.getPostalCode());
 
        /** 
         * result.append(address.getAddressLine(0) != null ?