Android Webview Onreceivederror Error Codes
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the android webview shouldoverrideurlloading workings and policies of this site About Us Learn more about Stack
Android Webviewclient Example
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs android webview shouldinterceptrequest Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join https://developer.android.com/reference/android/webkit/WebViewClient.html them; it only takes a minute: Sign up Detecting Webview Error and Show Message up vote 13 down vote favorite 3 I'd like to show an error message when there is an error loading a webview page (No connection). This is what I have so far, without the error handling code: public class TrackerPage extends Activity { // @Override http://stackoverflow.com/questions/6392318/detecting-webview-error-and-show-message private WebView webview; private ProgressDialog progressDialog; private boolean error; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get rid of the android title bar requestWindowFeature(Window.FEATURE_NO_TITLE); // Set the XML layout setContentView(R.layout.tracker_page); // Bundle objectbundle = this.getIntent().getExtras(); webview = (WebView) findViewById(R.id.tracker); final Activity activity = this; // Enable JavaScript and lets the browser go back webview.getSettings().setJavaScriptEnabled(true); webview.canGoBack(); webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } public void onLoadResource(WebView view, String url) { // Check to see if there is a progress dialog if (progressDialog == null) { // If no progress dialog, make one and set message progressDialog = new ProgressDialog(activity); progressDialog.setMessage("Loading please wait..."); progressDialog.show(); // Hide the webview while loading webview.setEnabled(false); } } public void onPageFinished(WebView view, String url) { // Page is done loading; // hide the progress dialog and show the webview if (progressDialog.isShowing()) { progressDialog.dismiss(); progressDialog = null; webview.setEnabled(true); } } }); // The URL that webview is loading webview.loadUrl("http://url.org/"); } } How would I do this? android user-interface error-handling webview share|improve this question edited Jun
here for a quick overview of the site Help Center Detailed answers to any questions http://stackoverflow.com/questions/13718789/how-to-handle-errors-inside-webview you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a android webview community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to handle errors inside webview? up vote 2 down vote favorite 1 I want to load a webpage. private class MyJavaScriptInterface { private MyJavaScriptInterface () { } public void setHtml(String contentHtml) { android webview onreceivederror if (contentHtml != null && contentHtml.trim().length() > 0) { //Do something } } } private WebViewClient webViewClient = new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { view.loadUrl("javascript:window.ResponseChecker.setHtml" + "(document.body.innerHTML);"); if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e("ProcessPayment", "onReceivedError = " + errorCode); } }; I want to handle webpage loading errors. I know that the errors can be obtained in onReceivedError(...) method. My problem is how can I handle the error without showing Page Not found in webview? (eg: Show a dialog and makes webview blank). Thanks in Advance. android webview webviewclient share|improve this question edited Dec 5 '12 at 8:16 Michaël 2,80272652 asked Dec 5 '12 at 8:10 Devu Soman 82542345 add a comment| 2 Answers 2 active oldest votes up vote 5 down vote accepted Check as: