Get the username of the current location in Arabic?
I need to get the name of the place in Arabic, if gps is allowed for English, I use the following code.
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();
}
Address [addressLines = [Abu Dhabi - United Arab Emirates "], feature = 3rd Street, admin = Abu Dhabi, sub-admin = null, area = Abu Dhabi, passing = third Street, postalCode = null, countryCode = AE, countryName = United Arab Emirates, hasLatitude = true, latitude =, hasLongitude = true, longitude =, phone = zero, URL = zero, additional = zero]
I need a locality value in Arabic based on the user selected language in the application.
i is given Locale mLocale = new Locale("ar","AE");
but it gives the name of the country assigning the Arabic language, I need the locality value in Arabic.
in galaxy s7 data arriving correctly based on Arab selection giving Arab data
s6 is not sent, it only gives English data if I also go to language Arabic.
source to share
In a recent link, Locale has information about the language / country code that fit in ISO 639-1 / ISO 3166-1.
ISO 639-1 is a lowercase two-letter code. Arabic is defined in this format.
You can set the locale for Arabic as follows:
Locale loc = new Locale("ar");
Note:
Android LAN Link: https://developer.android.com/reference/java/util/Locale.html
ISO 639-1 code reference: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
hope it works for you.
source to share