请看看这个.我正在尝试为特定时间和日期设置警报.它似乎没有用,我也不知道为什么.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.YEAR, mYear);
cal.set(Calendar.MONTH,mMonth);
cal.set(Calendar.DAY_OF_MONTH,mDay);
cal.set(Calendar.HOUR,mHour);
cal.set(Calendar.MINUTE,mMinutes);
// where mYear, mMonths, mDay, mHour and mMinutes are int values from the Date and Time picker dialogs respectively
Intent activate = new Intent(this, Alarm.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, activate, 0);
alarms = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
只是让您知道,如果我将alarms.set()方法中的cal.getTimeInMillis()替换为System.CurrentTimeInMillis(),它会起作用.但这显然就是我所不想要的.谢谢