Android Question How to track ERR_INTERNET_DISCONNECTED on WebView?

cenyu

Active Member
Licensed User
Longtime User
Hello, i have function that setup WebView:
SetupWebView:
Sub SetupWebView
    
    
    WebView1.Initialize("")
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
  
    WebViewExtras1.Initialize(WebView1)
    '   WebViewExtras1 now has all the methods and properties of WebView1 plus it's additonal methods and properties
    '   so you can use WebView1 to get/set WebView properties/methods
    '   or use WebViewExtras1 to get/set WebView1 properties/methods with the additional properties/method of WebViewExtras
  
  
    Dim JavascriptInterface1 As DefaultJavascriptInterface
    JavascriptInterface1.Initialize
    
    Dim settings As WebSettings = WebViewExtras1.GetSettings
    settings.SetCacheMode(settings.LOAD_DEFAULT)
    
    Dim WebViewClient1 As DefaultWebViewClient
    WebViewClient1.Initialize("WebViewClient1")
    
    
    WebViewExtras1.JavaScriptEnabled=True
    WebView1.JavaScriptEnabled = True
    WebViewExtras1.SetWebViewClient(WebViewClient1)
    WebViewExtras1.AddJavascriptInterface(JavascriptInterface1,"B4A")
    WebViewExtras1.Visible=False
    WebViewExtras1.ZoomEnabled = False
    
End Sub

Then i have loading external webiste: WebViewExtras1.LoadUrl(appAuthUrl)

I have this
Errors:
Sub WebViewClient1_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
    SslErrorHandler1.Proceed
    ToastMessageShow("No net", True)
End Sub



Sub WebView1_ReceivedError(ErrorCode As Int, Description As String, FailingUrl As String)
    
    ToastMessageShow("No net", True)
    
End Sub
for error tracking but nothing work. I can't get ERR_INTERNET_DISCONNECTED when site is loaded. Do you know how to do this?
 

drgottjr

Expert
Licensed User
Longtime User
the 2 errors you refer to are http-related, not network-related. a network-related problem will not trigger those events.

if disconnects are common, you should probably check the connection before you load a page, although a
disconnect can happen anytime. you could also try to wrap your page loads in a try/catch block. a disconnect during a page
load will probably cause an exception (and, perhaps, even a crash). the try/catch block should capture the disconnect, and
you can exit the app gracefully or maybe try again later.

depending on the website, once you've successfully loaded a page, a disconnect is irrelevant until you try to load the next
page, by which time, your connection may have been restablished.
 
Last edited:
Upvote 0
Top