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

Biswajit

Active Member
Licensed User
its possible for WebCromeClient?
i've tried, but failed
DefaultChromeClient does not raise any receive error event. So I think it's not possible with chrome client. Though you can attach chrome client along with webview client.
can't get screen auto rotation (phone lib) works..
I did not understand. Is it related to this class?
 

pemulanih

Member
1. ok thank for replying..i use defaultchromeclient.
2. i use phone orientation for overriderul for playing full screen video

B4X:
Sub wv_OverrideUrl (Url As String) As Boolean
    If Url.Contains("https://xxxxxx") Then
    p.SetScreenOrientation(0)
    Panel2.Visible=False
    Panel1.visible=False
        wv.BringToFront
    
    End If
    Return False
End Sub
when applying with DefaultWebClient , orientation didn't work 😢
 
Top