如何管理应用程序MainActivity上要取消的通知?

发布于 2024-12-23 14:17:59 字数 395 浏览 3 评论 0原文

我的应用程序中有很多通知。通过每个通知,我都会调用 myProject 的主要活动。

现在我的应用程序中有多个通知,例如 aNotification、BNotification。 。 。

我知道如何取消该通知。

即:

 NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
 notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_EVERY_MONTH);

但是如果有多个通知那么如何处理它?

谢谢。

I have Many Notification in My Application. By each Notification i am calling myProject's Main Activity.

Now there are Multiple Notification in My Application as like aNotification, BNotification. . .

I know how to cancel that notification.

i.e:

 NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
 notificationManager.cancel(NotificationConstants.NOTIFICATION_ID_EVERY_MONTH);

But if there are multiple Notification then how to handle it ??

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

囚我心虐我身 2024-12-30 14:17:59

管理多个通知的唯一方法是在通知它们时存储它们的 id

,即,

notificatonManager.notify(int id, Notification notification)

现在每次调用此函数时都需要存储“int id”,因为它在应用程序中是唯一的。然后您可以随时使用它来取消它。确保保持其唯一性,以便您可以正确管理每个通知......

Only way to manage multiple Notifications is to store their ids while notifying them

i.e,

notificatonManager.notify(int id, Notification notification)

Now you need to store the "int id" everytime you call this function as its unique within your app. Then later you can use it to cancel it whenever you want. Make sure to keep it unique so that you can manage every notificaion properly ....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文