【问题标题】:How to check if Automatic Time Zone check is enabled or not in android如何检查是否在android中启用了自动时区检查
【发布时间】:2016-02-11 06:06:13
【问题描述】:

我需要知道如何检查是否以编程方式在 android 设备中检查并启用了自动时区。

我通过这个问题了解了自动日期和时间:

Automatic Time and Date Check in Android

但现在需要知道自动时区。

【问题讨论】:

  • 问题不一样
  • 为什么它被否决了?

标签: android timezone


【解决方案1】:

您似乎可以使用AUTO_TIME_ZONE 而不是您在链接问题中看到的 AUTO_TIME。

【讨论】:

    【解决方案2】:

    如果时区设置为自动,则此函数返回 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;
                }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 2011-09-29
      • 2013-05-18
      • 2010-11-26
      • 1970-01-01
      相关资源
      最近更新 更多