Flo Flo - 4 months ago 14x
Android Question

Android notification doesn't disappear after clicking the notifcation

If got some issues with a notification I want to show in the notification bar. Although I set the notification flag to

Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL
the notification doesn't disappear after clicking it. Any ideas what I'm doing wrong?

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

int icon = R.drawable.icon;
CharSequence tickerText = "Ticker Text";
long time = System.currentTimeMillis();

Notification notification = new Notification(icon, tickerText, time);
notification.flags = Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL;

Context context = getApplicationContext();
CharSequence contentTitle = "Title";
CharSequence contentText = "Text";
Intent notificationIntent = new Intent(this, SilentFlipConfiguration.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL

From the documentation:

Bit to be bitwise-ored into the flags field that should be set if the notification should be canceled when it is clicked by the user