需要系统UID
AndroidManifest中:
系统UID:android:sharedUserId="android.uid.system"
修改系统时间的权限:<uses-permission android:name="android.permission.SET_TIME" />
类中:
private void setSysTime(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, 1); // add a day
long when = c.getTimeInMillis();
if (when / 1000 < Integer.MAX_VALUE) {
((AlarmManager) getSystemService(Context.ALARM_SERVICE)).setTime(when);
}
}