开发者

Android - WebViewClient

I am trying to load URL inside a WebViewClient as below:

webview.setWebViewClient(new WebViewClient()
{
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
             view.loadUrl(url);
             return true;
       }

    public void onPageFinished(WebView view, String url) 
       {
    }

     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) 
      {
   }
 });

 webview.loadUrl(articleLink);

Problem:

Web URL is loading successfully but in some occurrence i got the following errors, at the same time i would like to display Alert Dialog instead of Webview with Error message.

So can you please let me know ,How do i handle the following kind of errors:

  1. "Web page not available" error
  2. "Directory listing Denied"

I ha开发者_如何学Pythonve attached the 2nd one's image for your reference:

Android - WebViewClient


Both of those are server side errors. 1. is the page is either physically not there (404) or a 2. the server is serving you a page that states it will not show you the directory (200)

but you should be able to handle them inside the OnReceivedError() you can create a dialog box from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜