我很难从 DatePicker 和 TimePicker 创建警报...
这是我尝试的代码:
Calendar cal=Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
cal.set(Calendar.MONTH, datePicker.getMonth());
cal.set(Calendar.YEAR, datePicker.getYear());
cal.set(Calendar.HOUR, timePicker.getCurrentHour());
cal.set(Calendar.MINUTE, timePicker.getCurrentMinute());
long millis=cal.getTimeInMillis();
Intent intent=new Intent(CalendarView.this,AvisoReceiver.class);
PendingIntent mAlarmSender=PendingIntent.getBroadcast(CalendarView.this,23454546, intent,0);
AlarmManager alm=(AlarmManager)getSystemService(ALARM_SERVICE);
alm.set(AlarmManager.RTC_WAKEUP, millis,mAlarmSender);
但是当我从 TimePicker 和 DatePicker 设置我的闹钟时,我的接收器没有被调用。
如果我在呼叫接收器 3 秒后设置闹钟并收到通知。