6

Background

Android Lollipop (API 21) introduced a way to show notifications outside of the status bar (AKA "notifications bar"), so that the user can handle them right away. It's called "Heads-up notifications".

The trigger for showing them may vary between devices/roms/manufacturers.

The problem

Sometimes, showing such notifications can annoy users, and most of the times there are no settings for those cases.

If the user dismisses heads-up notifications, they won't show as a normal notification. There is no way to hide them and continue with what's on the screen. You can only wait (and it's quite a long time of waiting too).

In fact, there are multiple Google-Group issues that were opened about it, just because it can annoy people (link here and here).

What I've found

Starting with API 18, it is possible to listen to notifications events and even read them, by using "NotificationListenerService" and "StatusBarNotification" , and maybe other classes.

However, other than dismissing notifications (of other apps), I can't find any other action that can be done to them.

The question

Is it possible that in the lifetime of my app, I will be able to listen to notifications that are shown as heads-up, and put them back as a status-bar notifications?

Maybe even set a different timeout for them? or choose to convert them to normal status-bar notifications when they get dismissed?

Maybe before even doing those operations, I should ask: how can I know if a notification that I've found (of other apps) is showing as a heads-up notification ?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • it depends on its priority: if the priority is high or max *and* you set vibrate to the notification - it will "heads up" – dvrm Aug 05 '18 at 09:54

1 Answers1

0

I don't know how to do implement this. But answering the "Is it possible that...?" question, yes, there are apps like this one that block/only show notifications in the notification bar.

Teo Inke
  • 5,928
  • 4
  • 38
  • 37
  • I think you meant this one: https://play.google.com/store/apps/details?id=com.silverfinger.ticklrfree . Wonder how they all work. – android developer Jul 08 '15 at 15:53
  • It seems both have the same purpose. And yes, wonder how they work. They need full access to the device's notifications, I actually had to enable its permission on Settings -> Notification Manager -> Notification access (on Android 5.0). – Teo Inke Jul 08 '15 at 16:08
  • 1
    Please let me know if you find out. Maybe they draw a fake one of their own, and dismiss the normal notifications as they come. – android developer Jul 10 '15 at 22:42
  • HeadsOff definitely draws over the heads-up notification that's received. You can tell because normal heads-up notifications shows over the status bar and u can still see the status bar items behind it. But for HeadsOff, the status bar is just a blank bar. – Jason Hu Feb 13 '16 at 00:17
  • HeadsOff doesn't seem to work on Marshmellow even with the draw over. You can view the view layout bounds with "Show layout bounds" in the developer debug settings but the heads up notification sits on top of their system alert. – RyPope Jun 22 '16 at 19:40
  • @RyPope On Marshmellow you can disable these notifications natively, on Settings -> Notifications -> Heads up -> turn it off – Teo Inke Jun 23 '16 at 21:17