hand over an url to start a new activity

epistula

Member
Licensed User
Longtime User
Hi all,

i want to open different url's with only one webview activity. how can i hand over these urls to this activity? Like:

B4X:
Sub Button1_Click
   StartActivity(Webview) 'with Url1
End Sub

Sub Button2_Click
   StartActivity(Webview) 'with Url2
End Sub

Thank's!
 

klaus

Expert
Licensed User
Longtime User
You could declare a process global variable that holds the url.
B4X:
Sub Process_Globals
    Dim url As String
End Sub

Sub Button1_Click
    url = Url1
    StartActivity(WebView) 'with Url1
End Sub

Sub Button2_Click
    url = Url2
    StartActivity(WebView) 'with Url2
End Sub
And in the WebView activity you can get the url with Main.url

Best regards.
 
Upvote 0

epistula

Member
Licensed User
Longtime User
Great, thank's!

Only one question. Is there a way to "unload" the webview when i press the Home_button?

Now i have the problem that when i press Button1, then the Home_button, start the App again and press then Button2, that i see the url from button1.

I have played with some code, but i have no success right now. With the Back_button it works without problems (Activity.Finish).
 
Upvote 0
Top