android - 我如何清除按钮单击中的通知

标签 android

在我的项目中,我有通知选项。
我可以通过单击按钮删除此通知吗? 我可以使用代码单击此通知时取消通知

    checkin_notification.flags = Notification.FLAG_AUTO_CANCEL;

但我在我的应用程序中想在显示通知后清除它。它应该是单击按钮。

提前致谢。

最佳答案

清除所有您的应用程序的通知,您可以这样做,

NotificationManager notificationManager = (NotificationManager) 
                                 getSystemService(Context.
                                                        NOTIFICATION_SERVICE);
notificationManager.cancelAll();

要清除特定的通知,您可以这样做,

notificationManager.cancel(notification_id);

关于android - 我如何清除按钮单击中的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10171070/

相关文章:

android - 我如何使用数据绑定(bind)和 MVVM 捕获 RecyclerView 中的点击

android - ADB 无法识别三星 Galaxy S?

android - 从网址流式传输音频和视频?

android - Logcat 消息显示一段时间后就消失了吗?

android - XLabels 在 Android 4.3 的 achartengite 中相互重叠

java - WiFi getSSID() 总是返回 "<unknown ssid>"

android - 将Gradle Nature添加到Eclipse上的现有android项目

android - 谷歌身份验证后,即将到来的网址不允许我在 Cordova 应用程序中走得更远

Android 2.3.x 与谷歌图表

android - Activity onResume()