y07k2
y07k2

Reputation: 2052

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?

Upvotes: 0

Views: 447

Answers (1)

Ben
Ben

Reputation: 756

Why using the default Locale? This should work:

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

Upvotes: 2

Related Questions