My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
How to get application language and device language separately in android?
Asked Answered
Get system language
Resources.getSystem().getConfiguration().locale.getLanguage();
Get app language
String currentLang = Locale.getDefault().getLanguage();
What 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. –
Treed
Resources.getSystem().getConfiguration().locale.getLanguage() is deprecated –
Empery
if the language is english, does it return 'English' or 'en'? –
Viola
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")
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();
© 2022 - 2024 — McMap. All rights reserved.