How to get application language and device language separately in android?

断了今生、忘了曾经 提交于 2019-12-20 10:24:28

问题


My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?


回答1:


get system language

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

get app language

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



回答2:


This is the correct answer: getResources().getConfiguration().locale




回答3:


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();



回答4:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!