Is there any way to get System installed locales from the Android device. I tried with getAvailableLocales ()
from android Get Available locales, but it is not working for devices like Asus, Carbon, Lava, Intex.
For example, if I call getAvailableLocales()
in Nexus device I am able to get locales which is there in Settings-> Language&Input -> Language
But if I do same on any Carbon device, instead of getting languages from Settings-> Language&Input -> Language
, I get a different list.
I want only the installed list of languages in the device, not every language supported by OS.
This example demonstrate about how to Get the current language in Android device. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
Device locale - Android Tutorial Locale is the representation of a specific region.
When the Java virtual machine starts running on a computer, it creates an object called the default locale. This object affects the format of strings created from data. Depending on the default locale, a program creates different strings for the same number.
If you want system supported locales, use
Locale.getAvailableLocales()
If you want system supported and device enabled locales
Resources.getSystem().getAssets().getLocales()
By using the first one, you cannot be sure about if all locales are supported by that device. Cause they all came in with that Android ROM.
But the latter one is always a sure shot. Cause it gives only what all the locales(fonts) installed for that particular device. These locales(fonts) are placed by that device manufacturer.
I explained more it in here
The Locale.getAvailableLocales()
method is the generic 'base' set of locales. From the documentation:
Most locale-sensitive classes offer their own
getAvailableLocales
method, which should be preferred over this general purpose method.
Emphasis mine.
You can get the locales available for a specific use-case by querying the getAvailableLocales()
method on the appropriate class. Specifically:
BreakIterator.getAvailableLocales()
Collator.getAvailableLocales()
DateFormat.getAvailableLocales()
DateFormatSymbols.getAvailableLocales()
DecimalFormatSymbols.getAvailableLocales()
NumberFormat.getAvailableLocales()
Calendar.getAvailableLocales()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With