I need to get the current language selected in the Android device. When I use below code:
Log.v("Language: ", Locale.getDefault().getDisplayLanguage());
Log.v("Language: ", getResources().getConfiguration().locale.getDisplayLanguage());
The output is always same:
V/Language:: English
Below picture from android emulator selected language:
When I change the language of emulator, I can get the logs in the picture on the Android console.(But getDisplayLanguage() function returning English)
String locale = context.getResources().getConfiguration().locale.getDisplayName();
String locale = java.util.Locale.getDefault().getDisplayName();
They are different. The first can change if the user switches the Locale.
The second is the one that is pre-installed on the phone. It never changes no matter what the user does.
Happy Coding :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With