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

白昼怎懂夜的黑 提交于 2019-12-03 01:23:35

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