My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
get system language
Resources.getSystem().getConfiguration().locale.getLanguage();
get app language
String CurrentLang = Locale.getDefault().getLanguage();
This is the correct answer: getResources().getConfiguration().locale
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();
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")
来源:https://stackoverflow.com/questions/43092248/how-to-get-application-language-and-device-language-separately-in-android