private void addNotification1(String ss) { String ssBigText = ss; Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); NotificationManager nm = (NotificationManager)getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(getApplicationContext()) .setTicker("") .setContentTitle("") .setContentText(ss) .setSmallIcon(R.drawable.a) .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.logoapp)) .setOngoing(true) .addAction(0, "", intent).setAutoCancel(true); Notification notification = builder.getNotification(); long[] vibrate = new long[] { 0, 0, 200, 30, 10 }; notification.vibrate = vibrate; notification.priority =Notification.PRIORITY_MAX; notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT; nm.notify(NOTIFY_ID, notification); } I put the flag ongoing and the auto cancel flag but when I click it all the same does not close, what am I doing wrong?