Android Question All extras of Intent

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Any ready solution to get all extras from an intent as a map ?
It's for one shared processing sub of the Firebase push messages from
1) message As RemoteMessage (from FirebaseMessaging service) - here all is OK, map is ready...
and from
2) StartingIntent As Intent (from Activity where extras are only a bundle string)
 

peacemaker

Expert
Licensed User
Longtime User
What do you need it for?

It's for one shared processing sub of the Firebase push messages from.....
2 places. Parameters are in 2 different formats: map and ... a bundle string. Can "bundle" be some object ?


How is the current year related to the question?
The rules do not allow to continue an old forum topic.

Please edit the title and remove it.
OK, will do.

There is no method to convert the extras to a Map.
B4X:
Sub Get_Map_From_Bundle (bundle As String) As Map
    Dim res As Map
    res.Initialize
    If bundle.Trim = "" Then Return res
    'Bundle[{google.sent_time=1533742162225, google.ttl=2419200, tsj_address=%D0%B4%D0%BE%D0%BC+220%2C+%D1%83%D0%BB.+%D0%A1%D1%82%D0%B0%D1%80%D0%B0+%D0%97%D0%B0%D0%B3%D0%BE%D1%80%D0%B0%2C+%D0%B3.+%D0%A1%D0%B0%D0%BC%D0%B0%D1%80%D0%B0, body=987, from=/topics/general, title=TestTitle, google.message_id=0:1533742162621385%a2e646f5a2e646f5, collapse_key=peacemaker.testapp}]
    Dim res2 As String = bundle.SubString2(0, bundle.Length - 2).SubString(8)
    Dim pairs() As String = Regex.Split(", ", res2)
    For i = 0 To pairs.Length - 1
        Dim pair(2) As String = Regex.Split("=", pairs(i))
        res.Put(others.su.DecodeUrl(pair(0), "UTF8"), others.su.DecodeUrl(pair(1), "UTF8"))
    Next
    Log(res)
    Return res
End Sub
Sending user-entered parameters URLencoded...
 
Last edited:
Upvote 0
Top