使用getLanguage()方法和getCountry方法,获取系统设置的语言和区域。
//获取系统当前使用的语言
String lan = Locale.getDefault().getLanguage();
//获取区域
String country = Locale.getDefault().getCountry();
//设置成简体中文的时候,getLanguage()返回的是zh,getCountry()返回的是cn.
贴上getDefault()方法的api说明:
Locale java.util.Locale.getDefault()
public static Locale getDefault ()
Since:
API Level 1
Returns the user's preferred locale. This may have been overridden for this process withsetDefault(Locale)
.
Since the user's locale changes dynamically, avoid caching this value. Instead, use this method to look it up for each use.
贴上一个查询语言代号的网址:
http://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx