2

This question has already been asked by different users, e.g. here. But nevertheless, I need to repeat it as the provided answers do not help to get the CURRENT device language. My test device is in German language and the app in English. I try to get the current device language as follows:

  • Log.i("Language", Locale.getDefault().language)
  • Log.i("displayLanguage", Locale.getDefault().displayLanguage)

and both methods return:

  • I/Language: en
  • I/displayLanguage: English

which is not true. It should return something like this:

  • I/Language: de
  • I/displayLanguage: Deutsch

Do I do something wrong or there is a different way to get it done?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mark Delphi
  • 1,376
  • 1
  • 11
  • 29

1 Answers1

1

You can get the current device language by simply calling

Java

ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration());

Kotlin

ConfigurationCompat.getLocales(Resources.getSystem().configuration)

Shoaib Kakal
  • 1,090
  • 2
  • 16
  • 32