Hello everyone, I added a custom error message from Webview
to my app, however the default Android message still appears for a few seconds, how do I resolve it?
Here is the code:
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView webView, int errorCode, String description, String failingUrl) {
try {
webview.stopLoading();
} catch (Exception e) {
}
if (webView.canGoBack()) {
webView.goBack();
}
webview.stopLoading();
webview.loadUrl("about:blank");
AlertDialog alertDialog = new AlertDialog.Builder(Textures.this).create();
alertDialog.setTitle("Sem conexão");
alertDialog.setMessage("Para ver as texturas é preciso conexão com Internet!");
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alertDialog.show();
super.onReceivedError(webView, errorCode, description, failingUrl);
}
});
Whenever there is no internet the message appears, however as previously said the default message of Android appears a few seconds before.