如何获取iso3国家代码。当我存储服务器但它不存储100%的数据库?我正在使用这些代码。请帮助我谢谢并提前...
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();
}
答案 0 :(得分:1)
countryISO3 = context.getResources()。getConfiguration()。locale.getISO3Country()?
答案 1 :(得分:0)
您可以使用TelephonyManager:http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkCountryIso%28%29
这将使您获得所附网络的国家/地区。
答案 2 :(得分:0)
从国家/地区获取ISO代码:
TelephonyManager tm;
tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String loc = tm.getSimCountryIso();
Toast.makeText(SongsList.this, "LocaleName" + loc, Toast.LENGTH_LONG).show();