简体   繁体   中英

Android How to get system's installed locales

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.

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:

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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM