I want to disable my webview if an error message is displayed on the download. I use setWebViewClientbecause I need to use public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error).
I look around and see that I can use the method onProgressChanged(WebView view, int newProgress). Now I can not use this method in setWebViewClientand can not understand how to solve this problem. Another problem is that the progress bar never disappears after the page loads, I cannot add a breakpoint to the method public void onPageFinished(WebView view, String url).
Web view customization method:
public void WebViewSettings(){
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.canGoBack();
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals(urlString)) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
@Override
public void onLoadResource(WebView view, String url) {
if (progressDialog == null) {
progressDialog = new ProgressDialog(context);
progressDialog.setTitle("Loading...");
progressDialog.setMessage("Please wait.");
progressDialog.setIndeterminate(true);
progressDialog.show();
}
}
@Override
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
progressDialog = null;
webView.setEnabled(true);
}
}
@Override
public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
@Override
public void onReceivedError(WebView view, int errorCod,String description, String failingUrl) {
Toast.makeText(context, "Your Internet Connection May not be active Or " + description , Toast.LENGTH_LONG).show();
}
});
}
, , , - , -, - -, . , , , , .