Detecting Webview Error and Show Message

后端 未结 6 1737
鱼传尺愫
鱼传尺愫 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:33

    Add this after onpagefinished :

        public void onReceivedError(WebView view, int errorCod,String description, String failingUrl) {
                Toast.makeText(Webform.this, "Your Internet Connection May not be active Or " + description , Toast.LENGTH_LONG).show();
            }
    

    Don't forget to import android.widget.Toast;

提交回复
热议问题