码迷,mamicode.com
首页 > 移动开发 > 详细

Android获取当前系统语言

时间:2014-08-13 17:56:56      阅读:464      评论:0      收藏:0      [点我收藏+]

标签:des   android   style   blog   http   color   java   os   

private boolean isZh() {
        Locale locale = getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (locale.getLanguage().equals(new Locale("zh", "", "").getLanguage()))
            return true;
        else
            return false;
    }

 

参考:http://docs.oracle.com/javase/6/docs/api/java/util/Locale.html#getLanguage()

getLanguage

public String getLanguage()
Returns the language code for this locale, which will either be the empty string or a lowercase ISO 639 code.

NOTE: ISO 639 is not a stable standard-- some languages‘ codes have changed. Locale‘s constructor recognizes both the new and the old codes for the languages whose codes have changed, but this function always returns the old code. If you want to check for a specific language whose code has changed, don‘t do

 
 if (locale.getLanguage().equals("he")) 
    ... 
 
Instead, do
 
 if (locale.getLanguage().equals(new Locale("he", "", "").getLanguage())) 
    ...

 

See Also:
getDisplayLanguage()

Android获取当前系统语言,布布扣,bubuko.com

Android获取当前系统语言

标签:des   android   style   blog   http   color   java   os   

原文地址:http://www.cnblogs.com/veins/p/3910292.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!