filtering the NotificationListenerService object, Java/android

0

NotificationListenerService provides all the notifications on the device. Do you know how to filter them to display only those that are shown on the bar? The onNotificationPosted (StatusBarNotification sbn) method shows everything that is happening on the device, I just want to display notifications for the user

e.g

When I send a text message to my device, I will get 3 notifications, and I only want one - the last one with content, and I only want to take over the last one

1) D/VISIBILITY: 0 D/PACKAGENAME: com.xiaomi.simactivate.service D/NOTYFICATION: Notification(channel=com.xiaomi.simactivate.service.CHANNEL_ID pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x72 color=0x00000000 vis=PRIVATE) D/czas: Tue Dec 01 12:49:10 GMT+01:00 2020 I/Package: com.xiaomi.simactivate.service I/appname: Xiaomi SIM card activation service I/Title: Getting activation information ... I/Text: Getting activation information ...

2)

D/VISIBILITY: 0 D/PACKAGENAME: com.android.mms D/NOTYFICATION: Notification(channel=Mms_Default pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x62 color=0xff607d8b vis=PRIVATE) D/czas: Tue Dec 01 12:49:11 GMT+01:00 2020 I/Package: com.android.mms I/appname: SMS I/Title: The SMS application is running I/Text: Click to learn more or stop the application.

3) D/VISIBILITY: 0 D/PACKAGENAME: com.android.mms D/NOTYFICATION: Notification(channel=Channel_Msg_Default1583586283170 pri=1 contentView=null vibrate=default sound=content://settings/system/sms_received_sound tick defaults=0x2 flags=0x11 color=0x00000000 category=msg vis=PRIVATE) D/czas: Tue Dec 01 12:49:11 GMT+01:00 2020 I/Package: com.android.mms I/appname: SMS I/Title: +EHX90006ABC I/Text: test text

android
asked on Stack Overflow Dec 1, 2020 by macekmacek • edited Dec 1, 2020 by macekmacek

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0