任何人都知道我们如何以编程方式从应用程序中删除通知,该通知是使用待定 Intent 调用的。
我曾经使用以下方法取消通知。
AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(Display.this, TwoAlarmService.class);
PendingIntent pi = PendingIntent.getBroadcast(Display.this, AlarmNumber, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.cancel(pi);
但问题是已经触发但未从通知栏中删除的通知。
提前谢谢...
最佳答案
也许试试这个:
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
或者,您也可以这样做以取消给定上下文中的所有通知:
notificationManager.cancelAll();
请参阅此文档链接:NotificationManager
关于android - 如何在android中以编程方式从通知栏中删除通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19268450/