How to catch only visible notification? android

1

a have a small problem. Because, when I run a NotificationListenerService in background and method onNotificationPosted() give me a lot of notifications, but I need only this what see a user on the bar.

But, when somebody send me a message on Messenger, my service shows me a few notifications, and the same for sms end other apps. But I need only one, this with content for user. I tryed this:

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    int flag = sbn.getNotification().flags;
    flag = flag & 0x00000001;

    if (flag == 1) {
        //Do something
    }
}

And it works with app e.g Messenger, sms - I get only visible notification, but gmail not. I dont know why.

Somebody know how to get only visible notyfication for user ?

Please help

java
android
message
asked on Stack Overflow Dec 14, 2020 by macekmacek

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0