B4A Class Webview Custom Error Page

Biswajit

Active Member
Licensed User
This code module will return a custom HTML design along with the actual error message instead of the default webview error page.

Import the attached code module to your project and use it like below.

Usage:
B4X:
Sub Globals
    Private MainWebView As WebView
    Private WVE As WebViewExtras
    Private DWVC As DefaultWebViewClient
End Sub


Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("layout")
 
    DWVC.Initialize("WebViewClient")
    WVE.Initialize(MainWebView)
    WVE.SetWebViewClient(DWVC)

    WVE.LoadUrl("<your link>")
End Sub

Sub WebViewClient_ReceivedError(ErrorCode As Int, Description As String, FailingUrl As String)
    WVE.LoadHtml(CustomWebviewError.GetErrorPageHtml(Description))
End Sub
 

Attachments

Top