我希望能够在提示用户之后以编程方式检查此选项
像
这样的东西if (android.systemtime==false)
{
systemtime=true;
}
这可能吗?任何帮助将不胜感激
答案 0 :(得分:5)
您正在寻找Settings.System.AUTO_TIME
次设置(已在API级别17中移至Settings.Global.AUTO_TIME
)。在引入API级别17之前,您可以读取并更改该值,但现在此值对于非系统应用程序是只读的。
private boolean isAutoTimeEnabled() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// For JB+
return Settings.Global.getInt(getContentResolver(), Settings.Global.AUTO_TIME, 0) > 0;
}
// For older Android versions
return Settings.System.getInt(getContentResolver(), Settings.System.AUTO_TIME, 0) > 0;
}