0

I'm doing in-app notifications on Android. I'm using NotificationCompat.Builder and NotificationManager to do it. I set my notifications priority to PRIORITY_HIGH to display them as a popup.

But the notification is displayed in the Android notifications history. How to prevent this ?

Dazz Tv
  • 229
  • 1
  • 2
  • 6

1 Answers1

0

To cancel a notification you call

NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);

I would suggest calling this code after you create the pop up so that there is no notification left in the tray. I found this code here: How to clear a notification in Android

MacLean Sochor
  • 435
  • 5
  • 14
  • It works but on the device I tried it, the notification goes out really quicker. Is there a way to extend the duration of the notification ? – Dazz Tv Oct 09 '17 at 14:49