Android Question Webview Error

DawningTruth

Active Member
Licensed User
I have a webview setup. When I click on a url within the webview it crashes the app. Any suggestions?

Here is the error I get:

Error Message:
Error occurred on line: 357 (ViewSite)
java.lang.RuntimeException: Method: Initialize, Class: uk.co.martinpearman.b4a.webkit.WebViewExtras not matched.
    at anywheresoftware.b4a.shell.Shell.getMethod(Shell.java:668)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:774)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.WebViewWrapper$1.shouldOverrideUrlLoading(WebViewWrapper.java:64)
    at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
    at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-548106523:89)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:181)
    at android.app.ActivityThread.main(ActivityThread.java:7073)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

Here is the relevant code:

Relevant Code:
'Initialisation Code
    Private webViewExtras_ As WebViewExtras

'....

Sub wbv_WebContent_OverrideUrl (Url As String) As Boolean
     
    Private thisWebView As WebView = Sender

    Try
        'Setup WebView Extras
        webViewExtras_.Initialize(thisWebView) '## Get error here
       
    Catch
        Log(LastException)
        Return
    End Try

'Rest of code...
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
It's incorrect to initialize webview extras inside that subroutine.

Move that line to the the area where you do one-time initialization of your other views.
 
Upvote 0

DawningTruth

Active Member
Licensed User
Just corrected the code above.

it has this line in it:

B4X:
Private thisWebView As WebView = Sender

Which changes the way it works
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
See this post for how to use WebviewExtras:

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…