简体   繁体   English

Android Webview ERR_NAME_NOT_RESOLVED 加载 URL

[英]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.我有一个使用 Android Webview制作的应用程序,在使用 Wifi 连接时,加载的初始页面显示正常,切换到移动数据模式后,应用程序有时会显示ERR_NAME_NOT_RESOLVED消息。

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.感谢您的洞察力。

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.如果您的网络足够强大,请再次加载相同的页面。

You can check the url that is getting loaded in your webview by doing this.您可以通过执行此操作来检查在您的 web 视图中加载的 url。

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);    
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM