I can't seem to find an example on how to use the ReceivedError event of the WebViewExtras2 library.
I tried to use it to replace WebViewExtras (the old one) but I am getting a lot of errors. They seem to have different methods and ways of initializing.
Can anyone help please? An example on the following would be of great help for everyone trying to use the new WebViewExtras2 (version 2.20) library.
a. How to load a URL
b. How to check if there is error 404
c. How to execute Javascript in the WebView
d. How Javascript in the WebView can call a Sub in B4A
Was able to initialize, load URL, and execute a javascript in a WebView.
My remaining problem now is addJavascriptInterface doesn't seem to work with version 2.20. It's not calling the app's Sub's when I execute:
B4X:
<script>
function closeApp() {
APP.CallSub("Logout", true);
}
</script>
Here's my app code:
B4X:
Sub Globals
Dim LogonUrl As String = "file:///android_asset/test.htm"
Dim WebView1 As WebView
Dim WebViewExtras1 As WebViewExtras
End Sub
Sub Activity_Create(FirstTime As Boolean)
WebView1.Initialize("WebView1")
Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
WebView1.ZoomEnabled = False
WebViewExtras1.Initialize(WebView1)
WebViewExtras1.addJavascriptInterface(WebView1, "APP")
WebView1.LoadUrl(LogonUrl)
End Sub
Sub Logout
Activity.Finish
End Sub
1. Does the ChromeClient have anything to do with the addJavascriptInterface? I just need my javascript to be able to run Sub's in my app just like version 1.42 does with CallSub
2. I believe the ChromeClient is only used for the logs?
a. How to load a URL
b. How to check if there is error 404
c. How to execute Javascript in the WebView
d. How Javascript in the WebView can call a Sub in B4A