Android Question webview pass data in url(solved)

ronell

Well-Known Member
Licensed User
Longtime User
i have this code in my app
B4X:
webviewextras1.LoadUrl("https://sample/dashboard.php")

how can i pass variables in the url?

so that in webview .
B4X:
https://sample/dashboard.php?username=sampleusername
 

WaterDavid

New Member
Licensed User
Longtime User
Maybe you can do that
B4X:
Sub Globals
    Dim wv As WebView
    Dim URLs As String="https://sample/dashboard.php"
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    wv.Initialize("wv")
    Activity.AddView(wv,0,0,100%x,100%y)
    wv.LoadUrl(URLs)
End Sub

Sub ButtonEvent_Click
    URLs="https://sample/dashboard.php?username=sampleusername"
    wv.LoadUrl(URLs)
End Sub
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
tnx for the sample code! it gives me the idea to do this

B4X:
Sub Globals
  
    Private usertext As EditText
 

End Sub

Sub Globals
    Dim wv As WebView
    Dim URLs As String="https://sample/dashboard.php"
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")
    wv.Initialize("wv")
    Activity.AddView(wv,0,0,100%x,100%y)
    wv.LoadUrl(URLs)


End Sub

Sub ButtonEvent_Click
   
    dim user as string = usertext.Text
 

    URLs="https://sample/dashboard.php?username="&user
    wv.LoadUrl(URLs)
End Sub

the text in the edittext will be the username in URL. :)
 
Last edited:
Upvote 0
Top