即使创建了应用程序,我也必须将闹钟设置为10:35。但是当我这次安排的时候。我的应用程序因为日期过去而触发警报。我必须设置10:35。如果日期已过,我想在第二天10:35开始。我怎么能这样做?
我的代码:
Intent intent = new Intent(MainActivity.this, Alarm.class);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 35);
calendar.set(Calendar.SECOND, 40);
PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 234, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);