I send different notifications. But when you click on any one of them I get the data that have been sent to the last notification. how to fix it? I need to notice every store their data, and a new notice does not replace them.I use a flag PendingIntent.FLAG_UPDATE_CURRENT
but I use the left all the offers of flags too.
private void generateNotification(Context context, String title, String message,int groupid,Intent data) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Intent intent = new Intent(context,MyActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (groupid==1){
intent.putExtra("guest",data.getStringExtra("guest"));
intent.putExtra("hotel",data.getStringExtra("hotel"));
intent.putExtra("room",data.getStringExtra("room"));
}
if (groupid==5){
intent.putExtra("hotel",data.getStringExtra("hotel"));
}
if (groupid==4){
intent.putExtra("hotel",data.getStringExtra("hotel"));
intent.putExtra("guest",data.getStringExtra("guest"));
}
intent.putExtra("group_id",groupid);
Log.d("mylogout","group_id: "+groupid);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_gcm))
.setTicker("Новое сообщение")
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(message)
.build();
notificationManager.notify(ID_NITIF++, notification);
}