android - 获取 iso3 国家代码

标签 android

当我存储服务器但未存储 100% 数据库时,如何获取 iso3 国家代码?我正在使用这些代码。请帮助我,谢谢并提前...

     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();
    } 

最佳答案

关于android - 获取 iso3 国家代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9529032/

相关文章:

android - 如果另一个任务依赖于第一个任务运行,Gradle任务不会删除文件

java - 通知与行动

java - 重复的类com.google.api.Advice

android - 如何从Google git在Android Studio中构建项目,它没有gradle文件?

android - 在 Android 中从服务器获取时压缩视频

android - 如何在 ExpandableListView 中选择 child ?

Android 慢速文件下载与 iOS 和黑莓 - DefaultHttpClient

带边界的 Android 随机日期生成器

android - 无法显示网址图片(位图)

android - 请任何人都可以在 LogCat 中解释这个异常