4

I like to have a stck type notification for my message app which is a webapp. My notifications are working..But each time a new notification comes the previous notification dissapears and new one comes. When i googled i found that setGroup can be used. But whe i used it it is showing that

setGroup() is undefined for the type NotificationCompat.Builder.

My notification function is:

    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)
                        //At most three action buttons can be added
                        .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);
}
Karthik CP
  • 1,150
  • 13
  • 24
  • Possible duplicate of [Android - NotificationCompat.Builder stacking notifications with setGroup(group) not working](http://stackoverflow.com/questions/25031643/android-notificationcompat-builder-stacking-notifications-with-setgroupgroup) – Simon Jun 12 '16 at 11:06

2 Answers2

1

I had the same problem, but after several hours and many other problems i solved it. I assume you are using also Eclipse, otherwise the solution will be different.

You have to update your android in the SDK manager. Especially the Android SDK Build-Tools and afterwards you have to install API20. Now you have to update your ADT as described here: https://stackoverflow.com/a/24437737/2061089 Don't worry after the update its working now. Before you can install the update, you have to remove all components that you want to update.

After restarting eclipse you only have to update ALL your support(v4,v7 and v13) packages in your projects. Depending on what you are using.

Finished. Now everything is up to date and eveything is working.

Hope it helps!

Community
  • 1
  • 1
oli
  • 569
  • 6
  • 16
0

Change your notifyID from notificationManager.notify(notifyID, noti); every time when you make a new notification. It will solve the problem.

RusArtM
  • 1,116
  • 3
  • 15
  • 22