安卓2.1
代码:
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Intent intent = new Intent(this, AlarmReceiver.class);
intent.putExtra("message", header);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
当我不设置日期时间而只添加几秒钟时,它可以完美运行。
但是,当我确实设置了日期和时间(我从不同的活动中获取数据作为答案)时,它不起作用,我三次检查我得到的数据是否正确。
关于我做错了什么的任何建议?