【发布时间】:2016-02-11 06:06:13
【问题描述】:
我需要知道如何检查是否以编程方式在 android 设备中检查并启用了自动时区。
我通过这个问题了解了自动日期和时间:
Automatic Time and Date Check in Android
但现在需要知道自动时区。
【问题讨论】:
-
问题不一样
-
为什么它被否决了?
我需要知道如何检查是否以编程方式在 android 设备中检查并启用了自动时区。
我通过这个问题了解了自动日期和时间:
Automatic Time and Date Check in Android
但现在需要知道自动时区。
【问题讨论】:
您似乎可以使用AUTO_TIME_ZONE 而不是您在链接问题中看到的 AUTO_TIME。
【讨论】:
如果时区设置为自动,则此函数返回 1(true),否则如果未设置为自动时区,则返回 0(false)。
private boolean isTimeZoneAutomatic(Context c) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return Settings.Global.getInt(c.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0) == 1;
} else {
return android.provider.Settings.System.getInt(c.getContentResolver(), Settings.System.AUTO_TIME_ZONE, 0) == 1;
}
}
【讨论】: