'Android Webview ERR_NAME_NOT_RESOLVED loading an URL

I have an App made using Android Webview, while using Wifi connection the initial page loaded displays ok, after switching to mobile data mode, the application shows the ERR_NAME_NOT_RESOLVED message at times.

Is there a workaround to hide this message until the page is correctly displayed? or to make it work when the connection is not good in the initial load?

Thanks for the insight.



Solution 1:[1]

You can ask the user to retry at that point of time either displaying there or by showing a popup with a message. If you get the network is strong enough load the same page again.

Solution 2:[2]

You can check the url that is getting loaded in your webview by doing this.

myWebView.setWebViewClient(new WebViewClient() {
    @SuppressLint("NewApi")
    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
    }
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);    
    }
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jarvis
Solution 2 PurkkaKoodari