Ven*_*kat 5 android arabic geolocation
我需要以阿拉伯语获取位置名称,如果 gps 启用英语,我正在使用以下代码。
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
// LogCat: Display language = English
Log.i("Display language = ", "" + mLocale.getDisplayLanguage());
Log.i("geocoder geocoder = ", "" + geocoder.toString());
// Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
try {
List<Address> listAddresses = geocoder.getFromLocation(latitude, longitude, 1);
if (null != listAddresses && listAddresses.size() > 0) {
String _Location = listAddresses.get(0).getAddressLine(0);
// Log.i("_Location = ", "" + _Location);
Address address = listAddresses.get(0);
Log.i("address = ", "" + address);
result = address.getLocality();
Log.i("result = ", "" + result);
// Toast.makeText(getApplicationContext(), "Your Location NAME is -" + result , Toast.LENGTH_LONG).show();
}
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
地址[addressLines=[ Abu Dhabi - United Arab Emirates"],feature=3rd Street,admin=Abu Dhabi,sub-admin=null,locality=Abu Dhabi,thoroughfare=3rd Street,postalCode=null,countryCode=AE,countryName=阿拉伯联合酋长国,hasLatitude=true,latitude=,hasLongitude=true,longitude=,phone=null,url=null,extras=null]
我需要基于用户在应用程序中选择的语言的阿拉伯语位置值。
我给出了 Locale mLocale = new Locale("ar","AE");但它给出了来自阿拉伯语的国名我需要阿拉伯语的位置值。
在galaxy s7 中,基于阿拉伯语选择正确提供阿拉伯语数据的数据
s6 不来,它只在我通过语言环境阿拉伯语时才提供英文数据。
在最近的参考文献中,Locale 具有适用于 ISO 639-1/ISO 3166-1 的语言/国家代码信息。
ISO 639-1 是两个字母的小写语言代码。阿拉伯语就是以此格式定义的。
您可以像这样设置阿拉伯语区域设置:
Locale loc = new Locale("ar");
Run Code Online (Sandbox Code Playgroud)
笔记:
Android 区域设置参考:https://developer.android.com/reference/java/util/Locale.html
ISO 639-1 代码参考:https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
希望它对你有用。
| 归档时间: |
|
| 查看次数: |
1260 次 |
| 最近记录: |