我正在使用捆绑通知按类型对通知进行分组。当通知最大化时,从用户的角度来看,这非常好,如下所示:
但是,当摘要中的子通知被折叠时,这不能很好地工作:
现在,鉴于可以对此论坛中的所有通知执行相同的REGISTER
操作,我想让用户只需点击REGISTER ALL
就可以执行所有这些操作摘要通知中的操作。但是,对摘要添加操作似乎没有任何效果。下面的代码 - 我正在使用的代码 - 表明简单地忽略了对摘要通知的操作:
final PendingIntent actionIntent = PendingIntent.getService(this, 0, RegisterAllService.getRegisterAllServiceIntent(),PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Action action = new NotificationCompat.Action(R.mipmap.ic_launcher, "register all", actionIntent);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_notification)
.setAutoCancel(true)
.addAction(action)
.setGroup("confirmgroup")
.setGroupSummary(true);
NotificationManagerCompat.from(getApplicationContext()).notify(0, builder.build());
for(MyNotification myNotification: myNotifications){
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
final PendingIntent actionIntent = PendingIntent.getService(this, 0, RegisterService.getRegisterServiceIntent(),PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Action action = new NotificationCompat.Action(R.mipmap.ic_launcher, "register", actionIntent);
NotificationCompat.Builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_notification)
.setContentTitle(myNotification.getTitle())
.setStyle(new NotificationCompat.BigTextStyle().bigText(myNotification.getSubtitle()))
.setTicker(myNotification.getSubtitle())
.setContentText(myNotification.getSubtitle())
.setAutoCancel(true)
.addAction(action)
.setGroup("confirmgroup")
.setGroupSummary(false)
.setContentIntent(pendingIntent)
NotificationManagerCompat.from(getApplicationContext()).notify(myNotification.getId(), builder.build());
}
有没有办法让这种情况发生?