android - 单击删除所有通知

标签 android android-notifications

在我的应用程序中,我根据一些数据创建了 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/

相关文章:

android - Androids MediaPlayer onErrorListener MEDIA_ERROR_SERVER_DIED出现问题

xamarin - 在 Xamarin Forms Android 中处理通知

java - 如何为带有交互式通知的网络广播流创建 Android 前台服务?

android - 强制通知分组?

android - Android中如何将两个edittext的值相乘并自动在第三个EditText中显示结果

android - 比较字符串时间和当前时间android

android - 接到 voip 电话时如何将 Activity 带到前台?

android - 如何扩展只有一个附加行的 InboxStyle 通知?

android 在相机上显示矩形

android - 如何只扫描(单播扫描)一个特定的 AP 而不是扫描信道?