Skip to content Skip to sidebar Skip to footer

Run Different Functions Depending On Phone Language

I have support for 3 languages in my app. And depending on what language the phone is set to use I want my app to run a function based on that.

Solution 1:

You can determine this by looking for the devices Locale using the following syntax:

Localecurrent= getResources().getConfiguration().locale;

Solution 2:

Generally best practice is not to use different code for different languages, just use different resources. However if you still need it you can use the Locale class. If you want to get the selected language of your device:

Locale.getDefault().getDisplayLanguage();

If you're interested in just getting the ISO code (e.g. for if or switch statements) use:

Locale.getDefault().getISO3Language();

Solution 3:

if you want change the App language use the file strings for each language supported

Post a Comment for "Run Different Functions Depending On Phone Language"