检查Android手机是否具有特定的区域设置

时间:2012-08-25 06:04:44

标签: android localization

如何以编程方式检查手机是否具有特定区域设置?

1 个答案:

答案 0 :(得分:3)

您可以使用getAvailableLocales()获取Locale的数组,然后遍历它以查看它是否可用。

boolean hasLocale = false;
String myLocale = "en";
Locale[] locales = Locale.getAvailableLocales();
for (Locale locale : locales) {
    if (locale.getLanguage().equals(myLocale)) {
        hasLocale = true;
    }
}
// Value of `hasLocale` is what you want here!