在我的申请中,如果有3个通知,在点击任何通知我收到上次通知的数据。我正在为每个通知设置号码但是如果有多个通知我得到最后通知的数据。 这是我设置通知时的代码
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Calendar calendar = userSetMeetingDate;
calendar.set(Calendar.HOUR_OF_DAY, conferenceHour);
calendar.set(Calendar.MINUTE, conferenceMinute);
Bundle bundle = new Bundle();
bundle.putInt(KEY_CONFERENCE_ID, entity.getId());
Intent alarmIntent = new Intent(this, OnConferenceAlarmReceiver.class);
alarmIntent.putExtra(KEY_CONFERENCE_ENTITIY_BUNDLE, bundle);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, entity.getId(), alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
和
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(entity.getName())
.setContentText(entity.getConfrenceNumber())
.setContentIntent(pendingIntent)
.setVibrate(vibrate)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.addAction(android.R.drawable.ic_menu_call, "Call", pendingIntent)
//.addAction(android.R.drawable.ic_menu_edit, "Update", pendingIntent)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int) ((long) entity.getId());
notificationManager.notify(id, notification);
先谢谢