I want to make an app that can control how the notification window looks (i.e. the overlay the shows all your notifications when you swipe down from the top status bar). Is this possible? What APIs would I need to be able to do this (and know what notifications are current, etc)?
Related
is it possible to have notifications pop up, make a sound and be shortly visible at the top of the screen but not be logged via the notification center?
My idea is to have the user be notified of any important actions. But while the user is inside the app the notifications should not pool up inside the notification center. When the user is not actively using the app I will start a background service with a websocket and get further notifications for the user to be shown via the notification center.
So it it possible to differentiate between the two types. Similar to what whatsapp is doing?
One way to achieve the desired effect seems to be to just cancel the notification by ID once it has been passed to the notification manager:
https://developer.android.com/reference/android/app/NotificationManager#cancel(int)
I got a problem with Android Notification while developing my Messaging App.
My App need to clear notification on Status Bar, so I call Notification#cancel(id)
But this function also close the Chat Bubble relate to this Notification.
I tried hundreds way to clear Notification on Status Bar & keep Bubbles on Screen but can't
Any one here face this problem and has the solution yet?
Instead of cancelling the notification, you can republish it while calling setSuppressNotification(true) on it's bubble metadata & setOnlyAlertOnce(true) on its builder. It will keep the bubble and remove the notification along with the bubble badge and launcher shortcut badges, if any.
Beware that for this to work, your app must be visible on the screen.
I am developing an app to detect all the user actions performed on the screen. So how can I check if the user pulls down the notification bar?
Will this be possible with accessibility service??
As far as i know, there is no proper way to add a callback or any kinds of detection when the notification bar is pulled down.
That is because Android apps are meant to be designed in such a way that the interaction between the notification bar does not affect the functioning of the applications being used in any way.
I'm trying to create a custom notification in my android app with an image that will also be visible when the phone is locked.
Right now, Im building push notifications which are visible on the notification bar only, in which only my app icon is visible and on clicking which a certain pending intent is executed.
Is there a way through which i can show, my notifications with an image and a headline with it and also it gets visible on locked screen .
Also is there any widgets available or particular libraries through which i can implement my custom notifications?
Try using alertdialog with a flag. The flag_show_when_locked is the thing you trying to do I suppose. Please refer to this answer here.
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 ?
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.