Reputation: 24205
To find country name of the device current geo location in Android. The accurate way is using the longtude and latitude to get android.location.Address
object which contains getCountryName()
method.
My Question: Where can I find the full list of country names that Android uses? in other words, the list of countries that getCountryName()
get result from.
Upvotes: 0
Views: 1003
Reputation: 2594
it's in Locale
class.
Call getAvailableLocales()
then iterate the array & getDisplayCountry()
Locale[] locales = Locale.getAvailableLocales();
ArrayList<String> countries = new ArrayList<String>();
for (Locale locale : locales) {
String country = locale.getDisplayCountry();
countries.add(country);
}
Collections.sort(countries);
Output
Albania
Algeria
Argentina
Australia
..
Venezuela
Vietnam
Yemen
Upvotes: 2