Android:新信息替换通知中的旧信息 [英] Android: new information replace old information in notification
问题描述
来自 Android中NotificationManager
的文档:
公共无效通知(int id,通知通知) 发布要在状态栏中显示的通知.如果您的应用程序已经发布了具有相同ID的通知,但尚未取消,则该通知将被更新的信息替换.
public void notify (int id, Notification notification) Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.
it will be replaced by the updated information.
我不想替换旧信息,我希望两个通知. 注意:每个通知都有自己的ID:
I don't want the old information to be replaced, I want both notifications. NB: each notification has its own id:
notificationManager.notify(0, notification);
notificationManager.notify(1, notification);
该怎么做?
推荐答案
堆叠您的通知
如果您的应用在创建通知时仍未处理另一个相同类型的通知,请避免创建一个新的通知对象.而是堆叠通知.
If your app creates a notification while another of the same type is still pending, avoid creating an altogether new notification object. Instead, stack the notification.
堆叠式通知建立了摘要描述,并允许用户了解有多少种特定类型的通知待处理.
A stacked notification builds a summary description and allows the user to understand how many notifications of a particular kind are pending.
http://developer.android.com/design/patterns/notifications.html
这篇关于Android:新信息替换通知中的旧信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!