How to get application language and device languag

2020-05-20 02:50发布

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

4条回答
够拽才男人
2楼-- · 2020-05-20 02:50

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();
查看更多
劳资没心,怎么记你
3楼-- · 2020-05-20 02:53

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

查看更多
Melony?
4楼-- · 2020-05-20 03:16

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")
查看更多
Emotional °昔
5楼-- · 2020-05-20 03:17

get system language

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

get app language

String CurrentLang = Locale.getDefault().getLanguage();
查看更多
登录 后发表回答