我必须将意图值传递给服务类,但每次意图都采用与第一次相同的值,但我每次都需要不同的 意图值。
Intent alarmIntent = new Intent(AppointmentActivity.this,
AlarmService.class);
alarmIntent.putExtra("appDate", appDateString);
alarmIntent.putExtra("appTime", appoint_time);
alarmIntent.putExtra("appDesc", appoint_desc);
alarmIntent.putExtra("appRemind", appoint_remind);
sender = PendingIntent.getService(AppointmentActivity.this, 0,
alarmIntent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
答案 0 :(得分:0)
将PendingIntent.getService
替换为:
sender = PendingIntent.getService(AppointmentActivity.this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
看看它是否有效。
标记很重要,0
可能不是允许的值。