Android How to get locally installed systems

Is there a way to get the locales installed by the system from an Android device. I tried with getAvailableLocales () with android Get Available locales , but it does not work for devices like Asus, Carbon, Lava, Intex.

For example, if I call getAvailableLocales() on a Nexus device, I can get the locales that are in Settings-> Language&Input -> Language

But if I do the 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 ​​on the device, and not every language supported by the OS.

+7
android locale
source share
2 answers

If you want to support local systems, use

 Locale.getAvailableLocales() 

If you want system supported and locally enabled devices

 Resources.getSystem().getAssets().getLocales() 

Using the first one, you cannot be sure that all locales are supported by this device. Because they all came in with this Android ROM.

But the latter is always certain. Because it only gives that all locales (fonts) are installed for this particular device. These locales (fonts) are hosted by the manufacturer of this device.

I explained more in here

+3
source share

The Locale.getAvailableLocales() method is a common "base" set of locales. From the documentation:

Most language-sensitive classes offer their own getAvailableLocales method, which should be preferable to this general-purpose method .

Emphasis on mine.

You can get the locales available for a specific use case by getAvailableLocales() method in the corresponding class. In particular:

+5
source share

All Articles