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:
- "Web page not available" error
- "Directory listing Denied"
I ha开发者_如何学Pythonve attached the 2nd one's image for your reference:
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.
精彩评论