Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid webview onReceivedError() not working
    primarykey
    data
    text
    <p>I'm trying to show an alert box instead of 'Web page not available' error page on my web view but not working even after adding onReceivedError() method as per documentation, please suggest me if I'm missing something, Here is my code...</p> <pre><code>public class CloudPageHolder extends Activity { WebView mWebView; ProgressDialog _dialog ; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); mWebView.loadUrl("file:///android_asset/www/MyPage.html"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); mWebView.getSettings().setPluginsEnabled(false); mWebView.getSettings().setSupportMultipleWindows(false); mWebView.getSettings().setSavePassword(false); mWebView.getSettings().getAllowFileAccess(); mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); mWebView.getSettings().setUseWideViewPort(true); mWebView.getSettings().setLoadWithOverviewMode(true); mWebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { new AlertDialog.Builder(CloudPageHolder.this) .setMessage("Something went wrong!") .setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .setCancelable(false) .create() .show(); } }); mWebView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, final String message, final android.webkit.JsResult result) { new AlertDialog.Builder(CloudPageHolder.this) .setMessage(message) .setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.confirm(); } }) .setCancelable(false) .create() .show(); return true; } }); } </code></pre> <p>Thanks in Advance...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload