public AddressAssert hasLocality(String locality) { isNotNull(); String actualLocality = actual.getLocality(); assertThat(actualLocality) // .overridingErrorMessage("Expected locality <%s> but was <%s>.", locality, actualLocality) // .isEqualTo(locality); return this; }
private String getAddress(double latitude, double longitude) { StringBuilder result = new StringBuilder(); try { Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) { Address address = addresses.get(0); result.append(address.getLocality()).append("\n"); result.append(address.getCountryName()); } } catch (IOException e) { Log.e("tag", e.getMessage()); } return result.toString(); }
returnLocation.append(listAddresses.get(0).getAdminArea()); returnLocation.append(" "); returnLocation.append(listAddresses.get(0).getLocality()); theFrag.haveLocation = true; } catch (Exception e) {
returnLocation.append(listAddresses.get(0).getAdminArea()); returnLocation.append(" "); returnLocation.append(listAddresses.get(0).getLocality()); theFrag.isLocation = true; } catch (Exception e) {
List<Address> list = geoCoder.getFromLocation(location .getLatitude(), location.getLongitude(), 1); if (list != null & list.size() > 0) { Address address = list.get(0); result = address.getLocality(); return result;
List<Address> list = geoCoder.getFromLocation(location .getLatitude(), location.getLongitude(), 1); if (list != null & list.size() > 0) { Address address = list.get(0); result = address.getLocality(); return result;
List<Address> list = geoCoder.getFromLocation(location .getLatitude(), location.getLongitude(), 1); if (list != null & list.size() > 0) { Address address = list.get(0); result = address.getLocality(); return result;
if (myList != null && myList.size() > 0) { Address address = myList.get(0); String result = address.getLocality(); Toast.makeText(getApplicationContext(), ""+result, Toast.LENGTH_LONG).show(); }
List<Address> list = geoCoder.getFromLocation(location .getLatitude(), location.getLongitude(), 1); if (list != null & list.size() > 0) { Address address = list.get(0); result = address.getLocality(); return result;
List<Address> list = geoCoder.getFromLocation(location .getLatitude(), location.getLongitude(), 1); if (list != null & list.size() > 0) { Address address = list.get(0); result = address.getLocality(); return result;
private String getCityNameByCoordinates(double lat, double lon) throws IOException { List<Address> addresses = mGeocoder.getFromLocation(lat, lon, 10); if (addresses != null && addresses.size() > 0) { for (Address adr : addresses) { if (adr.getLocality() != null && adr.getLocality().length() > 0) { return adr.getLocality(); } } } return null; }
/** * 根据经纬度获取所在地 * * @param latitude 纬度 * @param longitude 经度 * @return {@link Address} */ public String getLocality(double latitude, double longitude) { Address address = getAddress(latitude, longitude); return address == null ? "unknown" : address.getLocality(); }
/** * 根据经纬度获取所在地 * * @param latitude 纬度 * @param longitude 经度 * @return 所在地 */ public static String getLocality(double latitude, double longitude) { Address address = getAddress(latitude, longitude); return address == null ? "unknown" : address.getLocality(); }
/** * 根据经纬度获取所在地 * * @param latitude 纬度 * @param longitude 经度 * @return 所在地 */ public static String getLocality(double latitude, double longitude) { Address address = getAddress(latitude, longitude); return address == null ? "unknown" : address.getLocality(); }
/** * 根据经纬度获取所在地 * * @param latitude 纬度 * @param longitude 经度 * @return 所在地 */ public static String getLocality(double latitude, double longitude) { Address address = getAddress(latitude, longitude); return address == null ? "unknown" : address.getLocality(); }
Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault()); Address address; List<Address> list; list = geocoder.getFromLocation(latitude,longitude,1);//33.64600, 72.96115 address = list.get(0); String cityname = address.getLocality(); String countryname = address.getCountryName(); Log.d("cityname",cityname.toString()); Log.d("countryname",countryname.toString());
public AddressAssert hasLocality(String locality) { isNotNull(); String actualLocality = actual.getLocality(); assertThat(actualLocality) // .overridingErrorMessage("Expected locality <%s> but was <%s>.", locality, actualLocality) // .isEqualTo(locality); 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(this, Locale.getDefault()); try { List<Address> addresses = gc.getFromLocation(lat, lng, 1); if (addresses.size() > 0) { Address address = addresses.get(0); String state = address.getLocality(); } } catch (IOException e) {}
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(); }