public AddressAssert hasSubAdminArea(String area) { isNotNull(); String actualArea = actual.getSubAdminArea(); assertThat(actualArea) // .overridingErrorMessage("Expected sub-admin area <%s> but was <%s>.", area, actualArea) // .isEqualTo(area); return this; }
public AddressAssert hasSubAdminArea(String area) { isNotNull(); String actualArea = actual.getSubAdminArea(); assertThat(actualArea) // .overridingErrorMessage("Expected sub-admin area <%s> but was <%s>.", area, actualArea) // .isEqualTo(area); return this; }
List<Address> addresses = new Geocoder(<CurrentActivityName>.this,Locale.getDefault()).getFromLocation(cur_lat, cur_lon, 1); Address addr= addresses.get(0); String Country=addr.getCountryName(); String State=addr.getSubAdminArea(); String City=addr.getLocality();
Geocoder gc = new Geocoder(context); if(gc.isPresent()){ List<Address> list = gc.getFromLocation(37.42279, -122.08506,1); Address address = list.get(0); StringBuffer str = new StringBuffer(); str.append("Name: " + address.getLocality() + "\n"); str.append("Sub-Admin Ares: " + address.getSubAdminArea() + "\n"); str.append("Admin Area: " + address.getAdminArea() + "\n"); str.append("Country: " + address.getCountryName() + "\n"); str.append("Country Code: " + address.getCountryCode() + "\n"); String strAddress = str.toString(); }
StringBuilder _homeAddress = null; try{ _homeAddress = new StringBuilder(); Address address = null; List<Address> addresses = _coder.getFromLocation(_lat,_lon,1); for(int index=0; index<addresses.size(); ++index) { address = addresses.get(index); _homeAddress.append("Name: " + address.getLocality() + "\n"); _homeAddress.append("Sub-Admin Ares: " + address.getSubAdminArea() + "\n"); _homeAddress.append("Admin Area: " + address.getAdminArea() + "\n"); _homeAddress.append("Country: " + address.getCountryName() + "\n"); _homeAddress.append("Country Code: " + address.getCountryCode() + "\n"); _homeAddress.append("Latitude: " + address.getLatitude() + "\n"); _homeAddress.append("Longitude: " + address.getLongitude() + "\n\n"); } } catch(Exception e){ }
public static String getAddress(Context context, Double latitude, Double longitude, boolean country, boolean fullAddress) { String add = ""; Geocoder geoCoder = new Geocoder(((Activity) context).getBaseContext(), Locale.getDefault()); try { List<Address> addresses = geoCoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { if (country) { add = addresses.get(0).getCountryName(); } else if (fullAddress) { add = addresses.get(0).getFeatureName() + "," + addresses.get(0).getSubLocality() + "," + addresses.get(0).getSubAdminArea() + "," + addresses.get(0).getPostalCode() + "," + addresses.get(0).getCountryName(); } else { add = addresses.get(0).getLocality(); } } } catch (IOException e) { e.printStackTrace(); } return add.replaceAll(",null", ""); }
result.city = addressList.get(0).getLocality(); if (TextUtils.isEmpty(result.city)) { result.city = addressList.get(0).getSubAdminArea();
public static String getCityAndCountryFromAddress(Address address) { if (address == null) { return ""; } String geoCity; if((address.getLocality() != null) && !"".equals(address.getLocality())) { geoCity = address.getLocality(); } else { geoCity = address.getSubAdminArea(); } if (geoCity == null) { geoCity = ""; } String geoCountryDistrict = null; if(address.getAdminArea() != null) { geoCountryDistrict = address.getAdminArea(); } String geoDistrictOfCity = address.getSubLocality(); String geoCountryName = address.getCountryName(); if ((geoDistrictOfCity == null) || "".equals(geoDistrictOfCity) || geoCity.equalsIgnoreCase(geoDistrictOfCity)) { if ((geoCountryDistrict == null) || "".equals(geoCountryDistrict) || geoCity.equals(geoCountryDistrict)) { return formatLocalityToTwoLines((("".equals(geoCity))?"":(geoCity)) + (("".equals(geoCountryName))?"":(", " + geoCountryName))); } return formatLocalityToTwoLines((("".equals(geoCity))?"":(geoCity + ", ")) + geoCountryDistrict + (("".equals(geoCountryName))?"":(", " + geoCountryName))); } return formatLocalityToTwoLines((("".equals(geoCity))?"":(geoCity + " - ")) + geoDistrictOfCity + (("".equals(geoCountryName))?"":(", " + geoCountryName))); }
cityName = addresses.get(0).getLocality(); if (cityName == null) { cityName = addresses.get(0).getSubAdminArea();
cityName = addresses.get(0).getLocality(); if (cityName == null) { cityName = addresses.get(0).getSubAdminArea();
try { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 10); if (!addressList.isEmpty()) { for (Address address : addressList) { String result = address.getAdminArea() != null ? address.getAdminArea() : "?"; result += " | "; result += address.getSubAdminArea() != null ? address.getSubAdminArea() : "?"; result += " | "; result += address.getLocality() != null ? address.getLocality() : "?"; result += " | "; result += address.getSubLocality() != null ? address.getSubLocality() : "?"; result += " | "; result += address.getThoroughfare() != null ? address.getThoroughfare() : "?"; result += " | "; result += address.getSubThoroughfare() != null ? address.getSubThoroughfare() : "?"; Log.i(TAG, result); } } } catch (IOException e) { Log.e(TAG, "Failed Geocoding."); }
private void updateLocation(Address address) { if (address != null) { Context context = mContext.getAndroidContext(); String parts[] = { address.getAdminArea(), address.getSubAdminArea(), address.getLocality(), address.getSubLocality(), address.getThoroughfare(), address.getSubThoroughfare(), address.getPremises(), address.getPostalCode(), address.getCountryName() }; String addressText = ""; for (int i = 0; i < parts.length; i++) { if (parts[i] == null || parts[i].isEmpty()) continue; if (!addressText.isEmpty()) { addressText += ", "; } addressText += parts[i]; } String text = String.format("%s : %s", DetailsHelper.getDetailsName( context, MediaDetails.INDEX_LOCATION), addressText); mListener.onAddressAvailable(text); } }
public static PersistableBundle fromAddress(android.location.Address address) { if (address == null) { return null; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { PersistableBundle persistableBundle = new PersistableBundle(); persistableBundle.putString("country", address.getLocale().getCountry()); persistableBundle.putString("language", address.getLocale().getLanguage()); persistableBundle.putString("variant", address.getLocale().getVariant()); persistableBundle.putString("locality", address.getLocality()); persistableBundle.putString("subLocality", address.getSubLocality()); persistableBundle.putString("adminArea", address.getAdminArea()); persistableBundle.putString("subAdminArea", address.getSubAdminArea()); persistableBundle.putString("countryName", address.getCountryName()); return persistableBundle; } else { return null; } } }
writeUTF(dos, address.getLocality()); writeUTF(dos, address.getAdminArea()); writeUTF(dos, address.getSubAdminArea());
public CustomAddress(Address address) { super(address.getLocale()); for (int i = 0; i <= address.getMaxAddressLineIndex(); i++){ super.setAddressLine(i, address.getAddressLine(i)); } super.setFeatureName(address.getFeatureName()); super.setAdminArea(address.getAdminArea()); super.setSubAdminArea(address.getSubAdminArea()); super.setLocality(address.getLocality()); super.setSubLocality(address.getSubLocality()); super.setThoroughfare(address.getThoroughfare()); super.setSubThoroughfare(address.getSubThoroughfare()); super.setPostalCode(address.getPostalCode()); super.setCountryCode(address.getCountryCode()); super.setCountryName(address.getCountryName()); super.setLatitude(address.getLatitude()); super.setLongitude(address.getLongitude()); super.setPhone(address.getPhone()); super.setUrl(address.getUrl()); super.setExtras(address.getExtras()); }