Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop heads-up notification being posted via Android Code?

I am building an android app that replaces the notification drawer and show notifications in its own window. I managed to show notifications on my drawer when they are posted by overriding onNotificationPosted() method. But, same notification is also shown by android. So,I want that notifications should be shown ONLY on my window, there are other apps who have done it,so it's not impossible. Please tell me how to override default behavior of android. Thanks in advance. :)

EDIT

What i want is to disable heads-up notification. Any solutions there?

like image 266
Dave Ranjan Avatar asked Nov 22 '25 08:11

Dave Ranjan


1 Answers

In Oreo and above OS It is in the Notification channel Where you have to set the Priority any thing lesser than NotificationManager.IMPORTANCE_HIGH or some thing like this below stops the heads up banner.

NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                                   CHANNEL_NAME, 
                                   NotificationManager.IMPORTANCE_DEFAULT)

On Pre-Oreo devices, the notification priority itself helps the system to show/hide the heads up banner. Also remember when you make this change you have to delete the app and reinstall to see the change!

like image 134
rana Avatar answered Nov 23 '25 22:11

rana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!