如何在 webview 上显示自定义错误信息

How to show custom error message on webview

我正在尝试为我使用 webview 的应用程序创建自定义错误消息。到目前为止,我正在使用下面的代码,它有一个非常小的问题...当我在 webview 上单击 links 时,页面正在重新加载同一页面而不是处理单击的 link。我在 webview 上的 links 正在下载 link 所以它应该使用相同的应用程序下载或打开下载程序选项

protected void fetch_web(){
    final WebView web;
    web = (WebView) findViewById(R.id.voice_mail_view_port);
    NoNetwork = (Button) findViewById(R.id.btn_no_internet);
    NoNetwork.setVisibility(View.GONE);
    String mdb = "http://192.168.23.1/default.php";

    getWindow().setFeatureInt(  Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
    final Activity MyActivity = this;
    web.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)
        {

            MyActivity.setTitle("Fetching feeds...");
            MyActivity.setProgress(progress * 100);

            loader();

            if(progress == 100) {
                MyActivity.setTitle(R.string.app_name);
                deLoader();;
            }
        }
    });
    web.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String
                failingUrl) {
            deLoader();
            alert("No Internet Connection","Let's get connected to see feeds");
            web.setVisibility(View.GONE);
            NoNetwork.setVisibility(View.VISIBLE);
        }
    });
    web.getSettings().setJavaScriptEnabled(true);
    web.loadUrl((mdb));
}
protected  void loader(){
    loading = (ProgressBar) findViewById(R.id.loader);
    loading.setVisibility(View.VISIBLE);
}
protected  void  deLoader(){
    loading = (ProgressBar) findViewById(R.id.loader);
    loading.setVisibility(View.INVISIBLE);
}

Sample download link http://192.168.23.1/download.php?id=1

谁能帮帮我,我怀疑我的错误来自这里

web.setWebViewClient(new WebViewClient() {
    public void onReceivedError(WebView view, int errorCode, String description, String
            failingUrl) {
        deLoader();
        alert("No Internet Connection","Let's get connected to see feeds");
        web.setVisibility(View.GONE);
        NoNetwork.setVisibility(View.VISIBLE);
    }
}); 

尝试强制该应用在其他浏览器中打开链接

Intent intent= new Intent(Intent.ACTION_VIEW,Uri.parse(url));
startActivity(intent);

如果失败,请告诉我更多帮助。