I searched for almost a day for this problem, I followed the example of Android Notification here: http://www.vogella.com/articles/AndroidNotifications/article.html . It worked well and I can send Notification . The problem is that when I click on the notification, it DOES NOT disappear, although I installed:
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 " + " test@gmail.com ") .setContentText("Subject"); Notification noti = builder.build(); noti.flags |= Notification.FLAG_AUTO_CANCEL; NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, noti);
Any ideas that raised the issue? Thanks for the help.
source share