Paresh Mayani
Paresh Mayani

Reputation: 128448

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 have attached the 2nd one's image for your reference:

alt text

Upvotes: 0

Views: 1906

Answers (1)

Dr.J
Dr.J

Reputation: 1218

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.

Upvotes: 3

Related Questions