【发布时间】:2020-02-01 14:16:16
【问题描述】:
我正在使用以下代码,并且我已经尝试了有关堆栈溢出的大部分答案,但它仍然为某些用户返回不同语言的位置。
会发生什么:
对于某些用户,即使我将默认语言设置为英语,它也会返回尼泊尔语的位置。我确实尝试过将手机的语言更改为尼泊尔语,但它以英语返回。
我的代码:
关于创建片段
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();
}
}
可能是什么原因?
【问题讨论】:
-
见also
-
听起来像这个功能请求:issuetracker.google.com/issues/63829150