本文整理了Java中android.location.Address.getCountryCode()
方法的一些代码示例,展示了Address.getCountryCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getCountryCode()
方法的具体详情如下:
包路径:android.location.Address
类名称:Address
方法名:getCountryCode
暂无
代码示例来源:origin: square/assertj-android
public AddressAssert hasCountryCode(String code) {
isNotNull();
String actualCode = actual.getCountryCode();
assertThat(actualCode) //
.overridingErrorMessage("Expected country code <%s> but was <%s>.", code, actualCode) //
.isEqualTo(code);
return this;
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public AddressAssert hasCountryCode(String code) {
isNotNull();
String actualCode = actual.getCountryCode();
assertThat(actualCode) //
.overridingErrorMessage("Expected country code <%s> but was <%s>.", code, actualCode) //
.isEqualTo(code);
return this;
}
代码示例来源:origin: geniusgithub/AndroidDialer
/**
* Given a {@link Location}, return a country code.
*
* @return the ISO 3166-1 two letter country code
*/
private String getCountryFromLocation(Context context, Location location) {
final Geocoder geocoder = new Geocoder(context);
String country = null;
try {
final List<Address> addresses = geocoder.getFromLocation(
location.getLatitude(), location.getLongitude(), 1);
if (addresses != null && addresses.size() > 0) {
country = addresses.get(0).getCountryCode();
}
} catch (IOException e) {
Log.w(TAG, "Exception occurred when getting geocoded country from location");
}
return country;
}
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: stackoverflow.com
Geocoder geocoder = new Geocoder(App.getContext(), Locale.US);
List<Address> listOfAddress;
try {
listOfAddress = geocoder.getFromLocation(theLatitude, theLongitude, 1);
if(listOfAddress != null && !listOfAddress.isEmpty()){
Address address = listOfAddress.get(0);
String country = address.getCountryCode();
String adminArea= address.getAdminArea();
String locality= address.getLocality();
}
} catch (IOException e) {
e.printStackTrace();
}
代码示例来源:origin: stackoverflow.com
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){
}
代码示例来源:origin: GrossumUA/TAS_Android_Boilerplate
String country = addresses.get(0).getCountryCode();
if (country != null) {
return country;
代码示例来源:origin: WangDaYeeeeee/GeometricWeather
result.country = addressList.get(0).getCountryName();
String countryCode = addressList.get(0).getCountryCode();
if (TextUtils.isEmpty(countryCode)) {
if (TextUtils.isEmpty(result.country)) {
代码示例来源:origin: jareddlc/OpenFit
CountryCode = addresses.get(0).getCountryCode();
Log.d(LOG_TAG, "Location: " + cityName + ", " + CountryCode);
代码示例来源:origin: jareddlc/OpenFit
CountryCode = addresses.get(0).getCountryCode();
Log.d(LOG_TAG, "onLocationChanged: " + cityName + ", " + CountryCode);
代码示例来源:origin: sephiroth74/Android-Exif-Extended
finalString.append( result.getCountryName() );
else if( null != result.getCountryCode() ) {
finalString.append( result.getCountryCode() );
代码示例来源:origin: stackoverflow.com
gps_stateName=address.getAdminArea().toString();
gps_cityName=address.getLocality().toString();
gps_countryCode=address.getCountryCode().toString();
Log.i("gps countrycode", gps_countryCode);
locationManager.removeUpdates(locationListener);
代码示例来源:origin: grzegorznittner/chanu
sCurrentAddress = currentAddress;
if (currentAddress != null && currentAddress.getCountryCode() != null) {
currentCity = checkNull(currentAddress.getLocality());
currentCountry = checkNull(currentAddress.getCountryCode());
currentAdminArea = checkNull(currentAddress.getAdminArea());
String addr1AdminArea = checkNull(addr1.getAdminArea());
String addr2AdminArea = checkNull(addr2.getAdminArea());
String addr1CountryCode = checkNull(addr1.getCountryCode());
String addr2CountryCode = checkNull(addr2.getCountryCode());
代码示例来源:origin: grzegorznittner/chanu
writeUTF(dos, address.getCountryCode());
writeUTF(dos, address.getPostalCode());
writeUTF(dos, address.getPhone());
代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android
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());
}
内容来源于网络,如有侵权,请联系作者删除!