Android webview custom error page

前端 未结 3 476
北荒
北荒 2021-02-05 12:41

I am creating application that use WebView to access a online website. I am stuck where I have to add code to check availability of page.

public class SpartanWeb         


        
3条回答
  •  滥情空心
    2021-02-05 13:21

    I added onReceivedError to mWebView.setWebViewClient(new WebViewClient so now it's working. Thanks for tips.

    mWebView.setWebViewClient(new WebViewClient() { 
            @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                   mWebView.loadUrl("file:///android_asset/error.html");
            } });
    

提交回复
热议问题