gpt4 book ai didi

android - 单击删除所有通知

转载 作者:行者123 更新时间:2023-11-30 02:04:55 25 4
gpt4 key购买 nike

在我的应用程序中,我根据一些数据创建了 3 个通知(id 为 0、1、2)。

我用

 setCancel(true);

在通知上,以便系统在用户单击时取消它。我想取消用户点击其中一个的所有通知(id 0,1,2)。这可能吗?

这是我关于创建通知的代码:

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, ActivityMain.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

Notification.Builder builder = new Notification.Builder(context);
Notification notification = null;

builder.setContentTitle(title)
.setContentIntent(contentIntent);

notification = new Notification.BigTextStyle(builder).bigText(mex).build();

notificationManager.notify(id, notification);

最佳答案

关于android - 单击删除所有通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30830130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com