获取iso3国家代码

时间:2012-03-02 06:30:38

标签: android

如何获取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();
    } 

1 个答案:

答案 0 :(得分:2)