Detecting Webview Error and Show Message

后端 未结 6 1740
鱼传尺愫
鱼传尺愫 2020-12-04 22:07

I\'d like to show an error message when there is an error loading a webview page (No connection). This is what I have so far, without the error handling code:



        
6条回答
  •  情话喂你
    2020-12-04 22:38

    All answer above are deprecated. You should use this code after on Page finished

     @Override
        public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error){
               //Your code to do
            Toast.makeText(getActivity(), "Your Internet Connection May not be active Or " + error.getDescription(), Toast.LENGTH_LONG).show();
        }
    

提交回复
热议问题