Android Question Get all the keys/values from a StatusBarNotification

cheveguerra

Member
Licensed User
Longtime User
Hi everybody,

I am playing with the NotificationListener Library and while I can get the already available keys from the SBN object (Id, PackageName and tickerText), I am trying to get all the other keys from the object:

B4X:
Sub Listener_NotificationPosted (SBN As StatusBarNotification)
    LogColor("NotificationPosted, package = " & SBN.PackageName & ", id = " & SBN.Id, Colors.red)
    Log($"Package=${SBN.PackageName}${CRLF}Id=${SBN.Id}"$)
    Dim p As Phone
    If p.SdkVersion >= 19 Then
        Log(SBN)
        Dim jno As JavaObject = SBN.Notification
        Dim extras As JavaObject = jno.GetField("extras")
        extras.RunMethod("size", Null)
        Dim title As String = extras.RunMethod("getString", Array As Object("android.title"))
        LogColor("Title = " & title, Colors.Blue)
    End If
End Sub

if I make a simple:

B4X:
log(SBN)

I can see a lot more keys "available", like pkg, tag, key, shortcut, groupKey, etc:

B4X:
(StatusBarNotification) StatusBarNotification(pkg=com.gbwhatsapp user=UserHandle{0} id=1 tag=E46WHLpM93PPM99cJkrB8ga7J4kfyDIB2uWU3a46ZqY=
 key=0|com.gbwhatsapp|1|E46WHLpM93PPM99cJkrB8ga7J4kfyDIB2uWU3a46ZqY= |10374: Notification(channel=silent_notifications_15 shortcut=5215554192439@s.whatsapp.net contentView=null vibrate=null sound=null defaults=0x0 flags=0x8 color=0xff008069 groupKey=group_key_messages sortKey=1 actions=2 vis=PRIVATE publicVersion=Notification(channel=null shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x0 color=0xff008069 category=msg vis=PRIVATE)))

Since the StatusBarNotification object is a special object I cannot cast it as map, so how would I go about getting these keys and their values?

Best regards
 
Top