获得ISO3国家code [英] get the iso3 country code
本文介绍了获得ISO3国家code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获得ISO3国家code.当我存储服务器,但它不是存储数据库的100%?我使用这些code.手电筒帮我感谢和高级...
地理codeR =新的地缘codeR(本);
locationManager =(LocationManager)getSystemService(LOCATION_SERVICE);
标准标准=新标准();
bestProvider = locationManager.getBestProvider(标准,FALSE);
位置= locationManager.getLastKnownLocation(bestProvider);
如果(位置!= NULL)
{
纬度= location.getLatitude();
LNG = location.getLongitude();
}
其他
{
位置=新的位置();
location.setLatitude((双)38.0000000000);
location.setLongitude((双)-97.0000000000);
纬度= location.getLatitude();
LNG = location.getLongitude();
}
Log.e(,经纬度+纵横=+纬度+经度=+ LNG);
尝试
{
地址=地理coder.getFromLocation(纬度,经度,1);
}
赶上(IOException异常E)
{
e.printStackTrace();
}
如果(地址=空&安培;!&安培; addresses.size()大于0)
{
地址地址= addresses.get(0);
Log.e(地址=,+地址);
区域= address.getCountry code();
Log.e(区域设置,+区域);
Toast.makeText(SongsList.this,LocaleName+区域,Toast.LENGTH_LONG).show();
}
解决方案
的 address.getLocale()getISO3Country();
How to get the iso3 country code.when i store the server but it is not store 100% of the database? I am using these code.Please help me Thanks and Advance...
geocoder = new Geocoder(this);
locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
bestProvider =locationManager.getBestProvider(criteria,false);
location = locationManager.getLastKnownLocation(bestProvider);
if(location!=null)
{
lat=location.getLatitude();
lng=location.getLongitude();
}
else
{
location = new Location("");
location.setLatitude((double)38.0000000000);
location.setLongitude((double)-97.0000000000);
lat =location.getLatitude();
lng=location.getLongitude();
}
Log.e("","Latitude and Longitude"+"Latitude="+lat+"Longitude="+lng);
try
{
addresses=geocoder.getFromLocation(lat,lng, 1);
}
catch (IOException e)
{
e.printStackTrace();
}
if (addresses != null && addresses.size() > 0)
{
Address address = addresses.get(0);
Log.e("Address=",""+address);
locale = address.getCountryCode();
Log.e("Locale",""+locale);
Toast.makeText(SongsList.this, "LocaleName"+locale,Toast.LENGTH_LONG).show();
}
解决方案
address.getLocale().getISO3Country();
这篇关于获得ISO3国家code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文