Android Question [SOLVED] Reading StatusBarNotification's extras

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
I am facing a problem I can't understand.

While trying to read some entries :

I get only :
android.title = null
android.infoText = 2 cartes

But
I get that time :
android.title = Casa
android.text = null
android.bigText = null

The code I am using is derived from the NotificationListener example :
B4X:
Sub Listener_NotificationPosted (SBN As StatusBarNotification)
    Log("NotificationPosted, package = " & SBN.PackageName & ", id = " & SBN.Id & _
        ", text = " & SBN.TickerText)
    Dim p As Phone
    If p.SdkVersion >= 19 Then
        Dim jno As JavaObject = SBN.Notification
        Dim extras As JavaObject = jno.GetField("extras")
        extras.RunMethod("size", Null)
        Log(extras)
        Dim title As String = extras.RunMethod("getString", Array As Object("android.title"))
        LogColor("Title = " & title, Colors.Blue)


        Dim StringToGet As List
        StringToGet.Initialize
        StringToGet.AddAll(Array As String("android.title","android.text","android.subText","android.bigText","android.infoText"))
       
        For loopMe=0 To StringToGet.Size-1
            Log($" ${StringToGet.Get(loopMe)} = ${extras.RunMethod("getString", Array As Object(StringToGet.Get(loopMe)))} "$)
        Next

    End If
End Sub

Please do you see why I can't get the values by fields depending on the notification ?
If I can not access the extras by field, how could I get the whole extras string to parse it ?

Many thanks