3
votes

How to programatically find the language the app is using. For example the device Locale is set to es_MX but my app supports only en_US and hence the app displays text only in English.

How to programatically find that app is using English and not Spanish in this case?

All the below code returns ex_MX

    Locale locale = getResources().getConfiguration().getLocales().get(0);
    Locale l = Resources.getSystem().getConfiguration().getLocales().get(0);
    Locale l1 = Locale.getDefault();
2

2 Answers

0
votes

Please Refer this given link's answer as you must get locale at the time of starting the app. If you will set your locale once in whole life cycle, you will get only the language as default as you set in the locale.

https://stackoverflow.com/a/23556454/6549856

0
votes

You can get the system language.

Resources.getSystem().getConfiguration().locale.getLanguage();

for app default language

String CurrentLanguage = Locale.getDefault().getLanguage();