簡體   English   中英

使用Android Geocoder getFromLocation獲取俄語的地址

[英]Get Address in Russian Language using Android Geocoder getFromLocation

我正在使用GeoCoder從lat和long中獲取地址。 這是我的代碼:

Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addressList = geocoder.getFromLocation(lat, lng, 1);

它可以用英語給我正確的地址。 我需要俄語的地址。 到目前為止,我嘗試將語言環境設置為俄語並將其傳遞給geocoder對象。

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);

但是我仍然用英語而不是俄語來獲得地址。 請建議我該怎么辦。

提前致謝。

試試這個代碼

        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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM