如何更新系统时间和时区? [英] How to update system time and time zone?
本文介绍了如何更新系统时间和时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新系统时间和时区.这是系统应用程序.因此,我授予了系统应用程序权限.我的代码是
I am trying to update the system time and time zone. This is system application. So I gave system application permissions. My code is
try {
AlarmManager alarmManager =
(AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.setTime(getSelectedDateFormat(mSelectedDateFormat)
.parse(mEtDate.getText() +" "+ mEtTime.getText()));
alarmManager.setTimeZone(mSpTimeZone.getSelectedItem().toString());
alarmManager.setTime(calendar.getTimeInMillis());
} catch (ParseException e) {
e.printStackTrace();
}
}
在这里,当我立即更新TimeZone和Time时,Time错误地更新了.如果我一个人更新时间,它会完美更新.知道我做错了什么吗?
Here when I update TimeZone and Time at a moment, Time is update wrongly. If I update time alone it update perfectly. Any idea what I am did wrong?
推荐答案
不允许所有系统应用程序更改时区.
All system apps are not permitted to change the time zone.
在您的应用程序的make文件中,确保您具有以下标记
In your application make file make sure that you have following tag
LOCAL_PRIVILEGED_MODULE := true
仅允许system/priv-app设置时区.
Only the system/priv-app are permitted to set the time zone.
这篇关于如何更新系统时间和时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文