public String getCountryCode(String countryName, String language) {
String[] isoCountryCodes = Locale.getISOCountries();
for (String code : isoCountryCodes) {
Locale locale = new Locale("de", code);
Log.d(TAG, "getCountryCode: " + locale.getDisplayCountry() + " " + code);
if (countryName.equalsIgnoreCase(locale.getDisplayCountry())) {
return code;
}
}
return "";
}
国家代码返回空。我该怎么解决?