I've been searching for almost a day for this problem, I followed the example about Android Notification here: http://www.vogella.com/articles/AndroidNotifications/article.html. It worked well and I can send the Notification
. The problem is, when I click on the notification, it does NOT disappear even though I have set:
setAutoCancel(true)
AND notification.flags |= Notification.FLAG_AUTO_CANCEL
Update: Here is my code
Intent intent = new Intent(MyNotification.this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(
MyNotification.this, 0, intent, 0);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(MyNotification.this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.addAction(R.drawable.ic_launcher, "Call", pIntent)
.addAction(R.drawable.ic_launcher, "More", pIntent)
.addAction(R.drawable.ic_launcher, "And more", pIntent)
.setContentTitle("New mail from " + "[email protected]")
.setContentText("Subject");
Notification noti = builder.build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
Any ideas where the problem come from? Thanks for your helps.
use this..
notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL
Android notification doesn't disappear after clicking the notifcation
Try removing:
noti.flags |= Notification.FLAG_AUTO_CANCEL;
It should work without noti.flags.
The new way of using flags in NotificationCompat is to use the defined methods, like setAutoCancel(true).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With