Я использую следующий код и перепробовал большинство ответов о переполнении стека, но для некоторых пользователей он по-прежнему возвращает местоположение на разных языках.
Что происходит:
Для некоторых пользователей, даже если я установил язык по умолчанию Engli sh, он возвращает местоположение на непальском языке. Я попробовал себя, изменив язык моего телефона на непальский, но он возвращается на английском языке sh.
Мой код:
при создании фрагмента
Locale.setDefault(Locale.ENGLISH);
LocationRetreive(locationLatitude, locationLongitude);
Метод
private void LocationRetreive(Double locationLatitude, Double locationLongitude) {
try {
Geocoder geocoder = new Geocoder(getContext(), Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(locationLatitude, locationLongitude, 1);
if (addresses != null && addresses.size() > 0) {
string_city = addresses.get(0).getLocality();
string_state = addresses.get(0).getAdminArea();
string_country = addresses.get(0).getCountryName();
string_location = addresses.get(0).getAddressLine(0);
if (string_country == null) {
if (string_state != null) {
string_country = string_state;
} else if (string_city != null) {
string_country = string_city;
} else {
string_country = "null";
}
}
if (string_city == null) {
if (string_state != null) {
string_city = string_state;
} else {
string_city = string_country;
}
}
if (string_state == null) {
if (string_city != null) {
string_state = string_city;
} else {
string_state = string_country;
}
}
if (string_location == null) {
string_location = "Null";
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
В чем может быть причина?