Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Is there a way to disable notification bundling?

I have an app where the user can receive multiple notifications for things they need to do. The user has a choice of making some of these notifications persistent (which I achieve by calling NotificationCompat.Builder.setOngoing). At least on my version of Android which is Nougat, when more than three notifications are posted by my app they get bundled together into one notification, which makes all of them dismissible to the user in one swipe. This makes the previously persistent notifications no longer persistent. Is there a way to programmatically instruct Android not to bundle my notifications?

This is the code I use to build the notification and display it:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setSmallIcon(R.drawable.ic_notification)
        .setContentTitle(eventName + " " + notificationText)
        .setDefaults(Notification.DEFAULT_ALL)
        .setOnlyAlertOnce(true)
        .setContentIntent(eventListPendingIntent);

if (goalInfo.goal.persistNotification) {
    builder.setOngoing(true);
} else {
    builder.setAutoCancel(true);
}

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(eventType.value(), builder.build());

Thanks, Nir

like image 977
Nir Arbel Avatar asked Feb 11 '17 00:02

Nir Arbel


People also ask

How do I stop notifications from stacking on Android?

To find it, launch the Settings menu on your phone, select Apps and notifications, and choose Notifications. Toggle the feature off and your notifications will start streaming in.

How do I turn off unremovable notifications on Android?

First, press-and-hold on the persistent notification you want to remove. Another option is to swipe the notification left or right, and then tap on the cogwheel icon shown next to it. Next, tap on the switch next to Permanent to disable it, and then press Save.

How do I turn off notifications for multiple Apps?

If you're on Android, head to Settings then open Apps & notifications. Tap See all apps, then choose the app you want to manage notifications for, and tap Notifications. The toggle switch at the top lets you turn notifications on or off for the app.


1 Answers

As per Google docs, notifications from the same app would be bundled automatically -

Note: If the same app sends four or more notifications and does not specify a grouping, the system automatically groups them together.

So in your case, what you can do is , instead of system applying the default grouping, you can separate your notifications into two groups using a separate group key for the persistent notifications and one for the non-persistent ones.

Check the Google docs. The method Builder.setGroup() on NotificationBuilderCompat takes a string parameter which is the key. There is a related method Builder.setGroupSummary which you should call on your Builder

Hope this is clear.

like image 107
Dibzmania Avatar answered Oct 04 '22 02:10

Dibzmania