我正在尝试构建一个警报应用程序。我之前有闹钟工作,我可以设置不同的时间,闹钟会适当地响起。然后我将 ChangeAlarmActivity 的布局更改为 TableLayout,现在它不起作用了吗?我没有触摸代码。以下是我设置闹钟的方法:
Intent alarmIntent = new Intent(ChangeAlarmActivity.this, AlarmReceiver.class);
PendingIntent pendingAlarmIntent = PendingIntent.getBroadcast(ChangeAlarmActivity.this, (int)alarm.getID(),
alarmIntent, 0);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
System.out.println("Alarm time: " + hour + ":" + min);
Calendar alarmCal = Calendar.getInstance();
//alarmCal.setTimeInMillis(System.currentTimeMillis());
alarmCal.set(Calendar.HOUR_OF_DAY, hour);
alarmCal.set(Calendar.MINUTE, min);
//alarmCal.set(Calendar.SECOND, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP,
alarmCal.getTimeInMillis(),
pendingAlarmIntent);