简体   繁体   English

获取国家/地区的英文名称而不是设备语言中的名称?

[英]Getting english name of country instead of name in device language?

How can I get english name of country instead of name in my choosen device language? 如何获取国家/地区的英文名称,而不是所选设备语言中的名称?

public static String getCountryName(Context context, double latitude, double longitude) {
    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    List<Address> addresses = null;
    try {
        addresses = geocoder.getFromLocation(latitude, longitude, 1);
        Address result;

        if (addresses != null && !addresses.isEmpty()) {
            return addresses.get(0).getCountryName();
        }
        return null;
    } catch (IOException ignored) {
        //do something
        return null;
    }
}

Can you help me? 你能帮助我吗?

Why using the default Locale? 为什么使用默认语言环境? This should work: 这应该工作:

Geocoder geocoder = new Geocoder(context, Locale.ENGLISH);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM