Use the NotificationManager to cancel your notification. You only need to provide your notification id.
https://developer.android.com/reference/android/app/NotificationManager.html
private static final int MY_NOTIFICATION_ID= 1234;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(MY_NOTIFICATION_ID, notification);
The example code is not complete. It depends on how your created your notification.
Just make sure you use the same id to cancel your notification as you used when you created your notification.
To cancel:
mNotificationManager.cancel(MY_NOTIFICATION_ID);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…