List of usage examples for android.location Address getThoroughfare
public String getThoroughfare()
From source file:it.feio.android.omninotes.utils.GeocodeHelper.java
public static String getAddressFromCoordinates(Context mContext, double latitude, double longitude) throws IOException { String addressString = ""; Geocoder geocoder = new Geocoder(mContext, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address address = addresses.get(0); if (address != null) { addressString = address.getThoroughfare() + ", " + address.getLocality(); }/* w w w .j a v a 2 s .c o m*/ } return addressString; }
From source file:com.dycody.android.idealnote.utils.GeocodeHelper.java
static String getAddressFromCoordinates(Context mContext, double latitude, double longitude) throws IOException { String addressString = ""; Geocoder geocoder = new Geocoder(mContext, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address address = addresses.get(0); if (address != null) { addressString = address.getThoroughfare() + ", " + address.getLocality(); }/*w w w .j a va 2 s. c o m*/ } return addressString; }
From source file:com.googlecode.android_scripting.jsonrpc.JsonBuilder.java
private static JSONObject buildJsonAddress(Address address) throws JSONException { JSONObject result = new JSONObject(); result.put("admin_area", address.getAdminArea()); result.put("country_code", address.getCountryCode()); result.put("country_name", address.getCountryName()); result.put("feature_name", address.getFeatureName()); result.put("phone", address.getPhone()); result.put("locality", address.getLocality()); result.put("postal_code", address.getPostalCode()); result.put("sub_admin_area", address.getSubAdminArea()); result.put("thoroughfare", address.getThoroughfare()); result.put("url", address.getUrl()); return result; }
From source file:es.rczone.tutoriales.gmaps.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { /**// w ww.j a v a 2s . com * Result for Address activity */ if (requestCode == 1) { if (resultCode == RESULT_OK) { Address current_location = data.getExtras().getParcelable("result"); LatLng addressLocation = new LatLng(current_location.getLatitude(), current_location.getLongitude()); CameraPosition camPos = new CameraPosition.Builder().target(addressLocation) //Center camera in 'Plaza Maestro Villa' .zoom(16) //Set 16 level zoom .build(); CameraUpdate camUpd3 = CameraUpdateFactory.newCameraPosition(camPos); map.animateCamera(camUpd3); String description = current_location.getThoroughfare() + " " + current_location.getSubThoroughfare() + ", " + current_location.getLocality() + ", " + current_location.getCountryName(); Marker m = map.addMarker(new MarkerOptions().position(addressLocation)); markersList.add(m); Toast.makeText(this, description, Toast.LENGTH_LONG).show(); } if (resultCode == RESULT_CANCELED) { // Write your code if there's no result } } }
From source file:org.egov.android.view.activity.CreateComplaintActivity.java
public String getCurrentLocation(double lat, double lng) { String cityName = ""; if (lat == 0 && lng == 0) { return ""; }// ww w . jav a2s .c om Geocoder geocoder = new Geocoder(CreateComplaintActivity.this, Locale.getDefault()); List<Address> addresses; try { addresses = geocoder.getFromLocation(lat, lng, 1); if (addresses.size() > 0) { Address address = addresses.get(0); cityName = address.getThoroughfare(); } } catch (IOException e) { e.printStackTrace(); } return cityName; }