Android: Getting a list of languages available for selecting by user

Android: Getting a list of languages available for selecting by user

In some cases you would like to get a list of languages which user is able to select on his/her Android phone. For example I have the following languages on my device:

You would expect this from Locale.getAvailableLocales(). But it returns the full list of locales supported by Android platform:[bg, bg_BG, ca, ca_ES, cs, cs_CZ, da, da_DK, de, de_AT, de_BE, de_CH, de_DE, de_LI, de_LU, el, el_GR, en, en_AU, en_BE, en_BW, en_BZ, en_CA, en_GB, en_HK, en_IE, en_IN, en_JM, en_MH, en_MT, en_NA, en_NZ, en_PH, en_PK, en_RH, en_SG, en_TT, en_US, en_US_POSIX, en_VI, en_ZA, en_ZW, es, es_AR, es_BO, es_CL, es_CO, es_CR, es_DO, es_EC, es_ES, es_GT, es_HN, es_MX, es_NI, es_PA, es_PE, es_PR, es_PY, es_SV, es_US, es_UY, es_VE, eu, fi, fi_FI, fil, fil_PH, fr, fr_BE, fr_CA, fr_CH, fr_FR, fr_LU, fr_MC, gl, iw, iw_IL, hi, hi_IN, hr, hr_HR, hu, hu_HU, in, in_ID, it, it_CH, it_IT, ja, ja_JP, ko, ko_KR, lt, lt_LT, lv, lv_LV, ms, nb, nb_NO, nl, nl_BE, nl_NL, pl, pl_PL, ps, pt, pt_BR, pt_PT, rm, ro, ro_RO, ru, ru_RU, ru_UA, sk, sk_SK, sl, sl_SI, sr, sv, sv_FI, sv_SE, th, th_TH, tr, tr_TR, uk, uk_UA, vi, vi_VN, zh, zh_CN, zh_HK, zh_HANS, zh_HANS_CN, zh_HANS_HK, zh_HANS_SG, zh_HANT, zh_HANT_HK, zh_HANT_MO, zh_HANT_TW, zh_MO, zh_SG, zh_TW]

Well, not the thing you’d like to see. To get the list of languages from the settings screen you can use the following code:


This code gives us what we need: [en_US, es_US]