I created a notification but once I click on it it does not remove! I even tried notification.setAutoCancel(true)
and notification.getNotification().flags |= Notification.FLAG_AUTO_CANCEL
Here is my code:
notification.setSmallIcon(R.drawable.message64);
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.setSound(uri);
Resources resources = getApplicationContext().getResources(),
systemResources = Resources.getSystem();
notification.setTicker("Notification");
notification.setContentTitle("Nouveau message");
notification.setContentText("Vous avez reçu un nouveau message. ");
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
notification.setContentIntent(pendingIntent);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notification.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
nm.notify(uniqueID,notification.build());
It is working well but it still doesn't remove it when I click on it.