I like to have a stck type notification for my messaging application which is webapp. My notifications work. But each time a new notification appears, the previous notification disappears and a new one appears. When I googled, I found that setGroup could be used. But I used it, it shows that
setGroup () is undefined for the type NotificationCompat.Builder.
My notification function:
public void CreateNotification(String msg)
{
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
Intent notificationIntent = new Intent(AndroidMobileAppSampleActivity.this, AndroidMobileAppSampleActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(AndroidMobileAppSampleActivity.this, 0, notificationIntent, 0);
NotificationManager notificationManager = (NotificationManager) AndroidMobileAppSampleActivity.this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification noti = new NotificationCompat.Builder(AndroidMobileAppSampleActivity.this)
.setSmallIcon(R.drawable.icon)
.setTicker("New message from "+msg)
.setWhen(System.currentTimeMillis())
.setContentTitle("Mybuzzin")
.setContentText(msg)
.setContentIntent(contentIntent)
.setAutoCancel(true).build();
noti.defaults |= Notification.DEFAULT_SOUND;
noti.defaults |= Notification.DEFAULT_VIBRATE;
noti.flags |=Notification.FLAG_SHOW_LIGHTS| Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(notifyID, noti);
}
source
share