I am using GeoCoder to fetch address from lat and long. here is my code:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addressList = geocoder.getFromLocation(lat, lng, 1);
It gives me address properly, but in English. I need the address in Russian language. What i have tried so far is to set locale to Russian language and pass it to geocoder object.
Locale aLocale = new Locale.Builder().setLanguage("RU").setScript("Latn").setRegion("RS").build();
Geocoder geocoder = new Geocoder(this, aLocale);
List<Address> addressList = geocoder.getFromLocation(lat, lng, 1);
But still i get address in English instead of Russian. Please suggest what should I do.
Thanks in advance.
Try this code
Locale aLocale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
aLocale = new Locale.Builder().setLanguage("RU").setScript("Latn").setRegion("RS").build();
} else {
aLocale = new Locale("RU");
}
Geocoder geocoder = new Geocoder(this, aLocale);
List<Address> addressList = geocoder.getFromLocation(lat, lng, 1);
Locale aLocale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
aLocale = new Locale.Builder().setLanguage("RU").setScript("Cyrl").setRegion("RS").build();
} else {
aLocale = new Locale("RU");
}
Geocoder geocoder = new Geocoder(this, aLocale);
List<Address> addressList = geocoder.getFromLocation(lat, lng, 1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.