First, set the system time
static void setTime(Context context, int hourOfDay, int minute) {
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hourOfDay);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
long when = c.getTimeInMillis();
/span>if ( when / 1000 < integer max_value {
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
}
}
Second, set the system date
static void SetDate ( context Context int year int month int day ) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, day);
long when = c.getTimeInMillis();
/span>if ( when / 1000 < integer max_value {
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
}
}
You also need to add the relevant permissions
<uses-permission android:name="android.permission.SET_TIME" />
From for notes (Wiz)
Android set system time and date method