Android Question WebView's PageFinished not being fired.

RobertJ

Member
Licensed User
Longtime User
Hello everyone, I am trying to make this code to work, it just seems that WebView's PageFinished event is not being fired after the url page load. I am using WebViewExtras2, the code runs but the event is not working. I can't find good examples and most of them seemed to be for ver 1.4.

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    
    Private wvExtras As WebViewExtras    
    Private WebViewClient As DefaultWebViewClient
    Private JavascriptInterface1 As DefaultJavascriptInterface
    Private WebViewChrome As DefaultWebChromeClient

   .... more code here, but ignored for this example...

End Sub


Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    B4XPages.SetTitle(Me, "MD GSSMobile")
    
    frmQRScanner.Initialize
    B4XPages.AddPage("QRScanner", frmQRScanner)

   
    urlView.JavaScriptEnabled = True

    JavascriptInterface1.Initialize
    wvExtras.Initialize(urlView)
    WebViewClient.Initialize("WebViewClient")
    wvExtras.SetWebViewClient(WebViewClient)
    WebViewChrome.Initialize("WebViewChrome")
    wvExtras.SetWebChromeClient(WebViewChrome)
    wvExtras.addJavascriptInterface(JavascriptInterface1, "B4X")

    ' Load the initial page
    urlView.LoadUrl("https://testing.com/index.aspx")

End Sub


Private Sub urlView_PageFinished (Url As String)   
    Dim sLine = Url
    
... more code here... 
End Sub
 
Solution
On your 1st suggestion, I changed it to just google.com and nothing. Now on your 2nd idea, I did commented out some of the WebViewClient and WEbViewChrome lines and now it works. I kept the JavaScriptInterface because later on, I want to read and write some values to the page.

Thank you very much. I'll try to find out more information on what are the WebViewClient and WebViewChrome classes.

Thank you.

modified:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    B4XPages.SetTitle(Me, "MD GSSMobile")
   
    frmQRScanner.Initialize
    B4XPages.AddPage("QRScanner", frmQRScanner)

    urlView.JavaScriptEnabled = True

    JavascriptInterface1.Initialize
    wvExtras.Initialize(urlView)...

RobertJ

Member
Licensed User
Longtime User
On your 1st suggestion, I changed it to just google.com and nothing. Now on your 2nd idea, I did commented out some of the WebViewClient and WEbViewChrome lines and now it works. I kept the JavaScriptInterface because later on, I want to read and write some values to the page.

Thank you very much. I'll try to find out more information on what are the WebViewClient and WebViewChrome classes.

Thank you.

modified:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    B4XPages.SetTitle(Me, "MD GSSMobile")
   
    frmQRScanner.Initialize
    B4XPages.AddPage("QRScanner", frmQRScanner)

    urlView.JavaScriptEnabled = True

    JavascriptInterface1.Initialize
    wvExtras.Initialize(urlView)
'    WebViewClient.Initialize("WebViewClient")
'    wvExtras.SetWebViewClient(WebViewClient)
'    WebViewChrome.Initialize("WebViewChrome")
'    wvExtras.SetWebChromeClient(WebViewChrome)
    wvExtras.addJavascriptInterface(JavascriptInterface1, "B4X")

    ' Load the initial page
    urlView.LoadUrl("https://www.google.com")

End Sub
 
Upvote 0
Solution
Top