Android 更新新通知

Android 更新新通知,android,notifications,Android,Notifications,我使用以下代码从服务获取通知 nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Intent intent = new Intent(this,test.class); PendingIntent pi = PendingIntent.getActivity(this, 0, intent,Notification.FLAG_AUTO_CANCEL); String

我使用以下代码从服务获取通知

nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        Intent intent = new Intent(this,test.class);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent,Notification.FLAG_AUTO_CANCEL);
        String body = "Hi this is test"+count;
        String title = "Ritu"+count;
        Notification n = new Notification(R.drawable.icon,body,System.currentTimeMillis());
        n.setLatestEventInfo(this, title, body, pi);
        n.defaults = Notification.DEFAULT_LIGHTS;
        n.number=++count;
        nm.notify(uniqueid, n);
每次我收到一个新的通知时,通知上的数字都会增加,但当我打开通知窗口时,我只能看到一个最新的通知,单击它后,通知的数字不会减少。 如果我错了,请帮助我


谢谢

尝试此操作,以便在单击后删除通知:

n.flags |= Notification.FLAG_AUTO_CANCEL;
而不是使用:

n.number = ++count;
使用:


这将允许您同时拥有多个通知

如果您可以获得帮助,请遵循此操作


我想我以前有过这个问题。我想android可能有漏洞,但我不记得了。尝试pendingent pi=pendingent.getActivity(this、uniqueid、intent、Notification.FLAG\u AUTO\u CANCEL);谢谢你的回复,但这不起作用:(,如果可能的话,你是如何解决你的问题的。如果我这样做,我会在状态栏上看到多个图标,第一个图标“2”上有“1”第二个图标等等。我希望它在状态栏上只显示一个图标,上面的数字会随着新通知的更新而更新,但我认为这是不可能的,因为我在这里读到通知管理器只支持每个项目一个图标,请建议您是否有其他方法。这是什么意思“其上的编号随新通知更新"?如果您一次只需要一个通知,请使用:顺便说一句,此标志|=notification.FLAG_AUTO_CANCEL;用于在单击后删除通知?问题是,当我打开通知窗口时,它不会显示图标中所示的所有通知,例如,通知显示有两个通知,但打开n通知窗口我只收到一个最新的通知。目前,如果状态栏上的图标上出现一个新的通知,则会发生什么情况?正在更新,但是,当我打开通知窗口时,我只收到一个最新的通知。也就是说,它没有显示所有通知,我希望m clear.n.flags |=Notification.FLAG_AUTO_CANCEL;
count++;
nm.notify(count, n);