Dec 23, 2014

get android device language



Sometime we need device's language.

Android provide class 'Locale'

Example
  1.         Locale mLocale = getResources().getConfiguration().locale;
  2.         String language = mLocale.getLanguage();
  3.         Log.e("lng",language);
  4.         if(language.contains("ko"))
  5.             in korean
  6.         else{
  7.             another language
  8.         }

Line 1 : Get country and language

Line 2 : Get language

Line 3 : show log

Line 4 : 'ko' mean korean. (english is 'en')

Line 6 : another language.

No comments:

Post a Comment