Android Question [SOLVED] Reading StatusBarNotification's extras


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

While trying to read some entries :

(Bundle) Bundle[{android.title=Porto - Lisboa : 18°, android.subText=null, android.showChronometer=false, android.icon=2130838475, android.text=Ensoleillé, android.progress=0, android.progressMax=0, android.showWhen=true, android.rebuild.applicationInfo=ApplicationInfo{dccc5e},, android.infoText=2 cartes, android.originatingUserId=0, android.progressIndeterminate=false}]
I get only :
android.title = null
android.infoText = 2 cartes

(Bundle) Bundle[{android.title=‪Casa‪, android.subText=null,$BigTextStyle, android.showChronometer=false, android.icon=2130837792, android.text=Test, android.progress=0, android.progressMax=0, android.showWhen=true, android.rebuild.applicationInfo=ApplicationInfo{314955b0}, android.people=[Ljava.lang.String;@a754c29,, android.bigText=Test, android.infoText=null, android.originatingUserId=0, android.progressIndeterminate=false}]
I get that time :
android.title = Casa
android.text = null
android.bigText = null

The code I am using is derived from the NotificationListener example :
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)
        Dim title As String = extras.RunMethod("getString", Array As Object("android.title"))
        LogColor("Title = " & title, Colors.Blue)

        Dim StringToGet As List
        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)))} "$)

    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