How to get application language and device language separately in android?
20,527
Solution 1
Get system language
Resources.getSystem().getConfiguration().locale.getLanguage();
Get app language
String currentLang = Locale.getDefault().getLanguage();
Solution 2
This is the correct answer: getResources().getConfiguration().locale
Solution 3
Kotlin - Android X:
val currentSysLocale = Resources.getSystem().getConfiguration().locales[0]
val currentAppLocale = Locale.getDefault().getLanguage()
Log.d("sys locale","$currentSysLocale")
Log.d("app locale","$currentAppLocale")
Solution 4
To Get System Language Use this:
String DeviceLang =Resources.getSystem().getConfiguration().locale.getLanguage();
And For the Application Language Use this:
String AppLang = Resources.getConfiguration().locale.getLanguage();
Author by
mob_web_dev
Updated on August 14, 2020Comments
-
mob_web_dev almost 4 years
My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
-
arekolek over 5 yearsWhat do you mean by "get app language"? In case the system is set to a language not supported by the app, both will return the system language, even though the app displays in a different language.
-
Agna JirKon Rx almost 5 yearsResources.getSystem().getConfiguration().locale.getLanguage() is deprecated
-
Ahmed Rajab over 3 yearsif the language is english, does it return 'English' or 'en'?