Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.NotificationManager; import android.content.Context; import android.support.annotation.NonNull; public class Main { public static final int NOTIFICATION_ID = 20111; public static void cancelNotification(@NonNull Context context, int id) { int finalId = id == 0 ? NOTIFICATION_ID : id; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(finalId); } }