Android Question How to parse URI into parameters ? (maybe AndroidNetUri lib)

peacemaker

Expert
Licensed User
Longtime User
Hi, All
Any template parsing code ?

Or how to use AndroidNetUri library ? I do not understand how to initialize it by the string URI.
 

peacemaker

Expert
Licensed User
Longtime User
example with the input and the desired output
Say,
B4X:
input_uri = "appsch://SetPhoto?ShowPreview=1&PhotoId=0"

And output map with keys for: schema, auth (login, password), host, root domain, port and parameters ...
Something this, more or less.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
you can write the parser yourself. It is all following rules where username and password are in the url, where a @ can be, where parameters are starting ect.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
anu.Initialize(Null)
Yes, it works. But it looks like no parsing all parameters, only whole query string is here ("ShowPreview=1&PhotoId=0").
But it can be already parsed manually.

@Ivica Golubovic, is it impossible to get all parameters by a lib function? Something like:
B4X:
    anu.Initialize(Null)
    anu.Parse("appsch://SetPhoto?ShowPreview=1&PhotoId=0")
    Dim q As String = anu.Query
    Dim query() As String = Regex.Split("&", q)
    Dim mParams As Map
    mParams.Initialize
    For i = 0 To query.Length - 1
        Dim record() As String = Regex.Split("=", query(i))
        mParams.Put(record(0), record(1))
    Next
    Log(mParams)
 
Last edited:
Upvote 0
Top