Reputation: 511
Whenever I receive a push notification on Android it replaces any existing notification in the drawer. any idea to fix that?
Below is my code:
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(DbInsertService.this, MessageActivity.class);
intent.putExtra("Service",serviceType);
PendingIntent pIntent = PendingIntent.getActivity(DbInsertService.this, (int)
System.currentTimeMillis(), intent,PendingIntent.FLAG_UPDATE_CURRENT);
Notification n = new Notification.Builder(DbInsertService.this)
.setContentTitle("Message from " +serviceType.getSer_name())
.setContentText(messageType.getHis_title())
.setSmallIcon(R.drawable.ic_email_variant_grey600_24dp)
.setContentIntent(pIntent)
.setAutoCancel(true).build();
notificationManager.notify(0, n);
thanks
Upvotes: 0
Views: 212
Reputation: 93561
You're sending them all with the same id. Send different ids and they won't overwrite.
Upvotes: 0
Reputation: 111
Set different Id for different notification.
notificationManager.notify(0, n);
// here set different Id.
Upvotes: 1