我需要创建 2 个通知,但如果我最后使用 FLAG_UPDATE_CURRENT 或 FLAG_CANCEL_CURRENT,它们都会获得相同的额外通知,否则使用第一个。
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
for(int num=1;num<3;num++){
Intent intent = new Intent(this, ActivityNotification.class);
intent .putExtra("reminder_id", num);
PendingIntent pi = PendingIntent.getActivity(this, num, intent , 0);
// PendingIntent pi = PendingIntent.getActivity(this, num, intent , PendingIntent.FLAG_UPDATE_CURRENT);
Notification noti = new Notification.Builder(this)
.setContentIntent(pi)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.drawable.noti)
.setWhen(when)
.setAutoCancel(true)
.build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(num, noti);
}
我怎样才能有不同的附加功能?或者一般来说,我的 ActivityNotification 怎么知道是哪个通知调用了它?