How to show a website in WebView

Penfound

Active Member
Licensed User
Longtime User
I am trying to display a webpage whose URL is drawn from an SQLite DB and read into the variable strLinkURL. There are two type of URL in the DB one is a YouTube video and the other wll always start with www. Can anyone tell where I've gone wrong...

Sub btnYTLink_Click
Select strLinkURL
Case "http://m.youtube.com/*"
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, strLinkURL )
Intent1.SetComponent("com.google.android.youtube/.WatchActivity")
Intent1.PutExtra("", strLinkURL )
StartActivity(Intent1)
Case "http://www.*"
Dim WebShow As WebView
WebShow.Initialize("webshow")
Activity.addview(WebShow,0,0,100%x,100%y)
WebShow.LoadUrl(strLinkURL)
StartActivity(WebShow)
End Select
End Sub

Cheers from Penfound
:BangHead:
 

pluton

Active Member
Licensed User
Longtime User
Hi Penfound

Did you try something like this:

B4X:
If strLinkURL.Contains("http://m.youtube.com/") Then
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, strLinkURL )
Intent1.SetComponent("com.google.android.youtube/.WatchActivity")
Intent1.PutExtra("", strLinkURL )
StartActivity(Intent1) 
End If

If strLinkURL.Contains("http://www.") Then
Dim WebShow As WebView
WebShow.Initialize("webshow")
Activity.addview(WebShow,0,0,100%x,100%y)
WebShow.LoadUrl(strLinkURL)
StartActivity(WebShow)
End If

Or you can use something like:
B4X:
If strLinkURL.IndexOf("www") 'or youtube
 
Upvote 0
Top