我有一个应用程序,用户可以收到他们需要做的事情的多个通知.用户可以选择使其中一些通知持久化(我通过调用NotificationCompat.Builder.setOngoing来实现).至少在我的Android版本Nougat上,当我的应用程序发布了三个以上的通知时,它们被捆绑在一起作为一个通知,这使得所有这些通知在一次刷卡中对用户是不允许的.这使先前持久的通知不再持久.有没有办法以编程方式指示Android不捆绑我的通知?
这是我用来构建通知并显示它的代码:
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());
Run Code Online (Sandbox Code Playgroud)
谢谢,Nir