public AddressAssert hasPostalCode(String code) { isNotNull(); String actualCode = actual.getPostalCode(); assertThat(actualCode) // .overridingErrorMessage("Expected postal code <%s> but was <%s>.", code, actualCode) // .isEqualTo(code); return this; }
/** * Try to get Postal Code * @return null or postalCode */ public String getPostalCode(Context context) { List<Address> addresses = getGeocoderAddress(context); if (addresses != null && addresses.size() > 0) { Address address = addresses.get(0); String postalCode = address.getPostalCode(); return postalCode; } else { return null; } }
public AddressAssert hasPostalCode(String code) { isNotNull(); String actualCode = actual.getPostalCode(); assertThat(actualCode) // .overridingErrorMessage("Expected postal code <%s> but was <%s>.", code, actualCode) // .isEqualTo(code); return this; }
private String AddressFromLatLng(LatLng myLatLng) { Geocoder geocoder; List<Address> addresses; geocoder = new Geocoder(this, Locale.getDefault()); String address="Current Location"; try { addresses = geocoder.getFromLocation(myLatLng.latitude, myLatLng.longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 if(addresses.size()>0) { address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex() String city = addresses.get(0).getLocality(); String state = addresses.get(0).getAdminArea(); String country = addresses.get(0).getCountryName(); String postalCode = addresses.get(0).getPostalCode(); String knownName = addresses.get(0).getFeatureName(); } } catch (IOException e) { e.printStackTrace(); } return address; }
private void fetchLocation(Location location) { List<Address> addresses; Geocoder geocoder = new Geocoder(ctx, Locale.getDefault()); try { ADLocation adLocation=new ADLocation(); addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); adLocation.address= addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex() adLocation.city=addresses.get(0).getLocality(); adLocation.state= addresses.get(0).getAdminArea(); adLocation.country = addresses.get(0).getCountryName(); adLocation.pincode= addresses.get(0).getPostalCode(); adLocation.lat=location.getLatitude(); adLocation.longi=location.getLongitude(); locListener.whereIAM(adLocation); }catch (Exception e){ e.printStackTrace(); } }
sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName());
sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName());
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", ""); }
private String AddressFromLatLng(LatLng ll) { Geocoder geocoder; List<Address> addresses; geocoder = new Geocoder(this, Locale.getDefault()); String address=""; try { addresses = geocoder.getFromLocation(ll.latitude, ll.longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5 if(addresses.size()>0) { address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex() String city = addresses.get(0).getLocality(); String state = addresses.get(0).getAdminArea(); String country = addresses.get(0).getCountryName(); String postalCode = addresses.get(0).getPostalCode(); String knownName = addresses.get(0).getFeatureName(); } } catch (IOException e) { e.printStackTrace(); } return address; }
sb.append(address.getPostalCode()).append("\n"); sb.append(address.getCountryName());
if( null != result.getPostalCode() ) { finalString.append( result.getPostalCode() );
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); } }
writeUTF(dos, address.getPostalCode()); writeUTF(dos, address.getPhone()); writeUTF(dos, address.getUrl());
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()); }