You don’t need to create Timestamp
s. You can do it with your Calendar
.
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
calendar.set(Calendar.MINUTE, minute);
if(calendar.before(Calendar.getInstance())) {
calendar.add(Calendar.DATE, 1);
}
alarmManager.set(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), pendingDinnerIntent);
I would also mention that as of KitKat, if your targetSdkVersion
is 19 or above, the AlarmManager#set()
method is not exact. If you want your alarm to fire at an exact time, you’ll need to use a setExact*()
method.