首页 > 代码库 > Android获取当前系统语言
Android获取当前系统语言
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, doif (locale.getLanguage().equals(new Locale("he", "", "").getLanguage())) ...
- See Also:
getDisplayLanguage()
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。