Android Webview Error Loading Page
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Android Webview Custom Error Page
and policies of this site About Us Learn more about Stack Overflow android webview loading listener the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Android Webview Loading Indicator
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 them; android webview loading in browser it only takes a minute: Sign up Android WebView onReceivedError() up vote 27 down vote favorite 6 Does anyone know if there is a way to intercept a "page not found" or "page not loading error" in WebView? According to the android documentation, onReceivedError() should be able to intercept. but i tested it in an app which I deleberately gave android webview loading spinner the wrong URL, and it didn't do anything. I want my app to be able to give my own custom error message if the URL is ever unavailable for any reason. this is the code that did nothing: public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // custom error handling ... show and alert or toast or something } android webview share|improve this question edited Sep 26 '11 at 9:55 Octavian Damiean 30.3k178091 asked Feb 14 '11 at 21:49 Joe Winfield 2513714 add a comment| 3 Answers 3 active oldest votes up vote 26 down vote According to documentation and my experience it should work quite fine. You just have to set your WebClient with overriden method onReceivedError in your WebView. Here is the snippet from some of my old test app: WebView wv = (WebView) findViewById(R.id.webView); wv.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.i("WEB_VIEW_TEST", "error code:" + errorCode); super.onReceivedError(view, errorCode, description, failingUrl); } }); I've tested it and it works quite fine. Check your logs and
here for a quick overview of the site Help Center Detailed
Android Webview Loading Too Slow
answers to any questions you might have Meta Discuss android webview example the workings and policies of this site About Us Learn more about Stack Overflow the
Android Webview Javascript
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss http://stackoverflow.com/questions/4997677/android-webview-onreceivederror Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up android webview error Page not found up vote 4 down vote favorite I use webVIew read local HTML. HTML storage http://stackoverflow.com/questions/14410725/android-webview-error-page-not-found location Project for asset Some phones can be successfully used(samsung...) Some phones can not(HTC nexus...) Here is my code public class MainActivity extends Activity { private WebView wvBrowser; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); findViews(); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (wvBrowser.canGoBack() && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { wvBrowser.goBack(); return true; } return super.onKeyDown(keyCode, event); } private void findViews() { wvBrowser = (WebView) findViewById(R.id.Browser); //wvBrowser.loadUrl(getString(R.string.googleUrl)); wvBrowser.getSettings().setSupportZoom(true); wvBrowser.getSettings().setBuiltInZoomControls(true); wvBrowser.loadUrl("file:///android_asset/ts.htm"); } } android html webview assets share|improve this question edited Jan 19 '13 at 8:30 seaplain 656623 asked Jan 19 '13 at 3:08 HLto Dm 1361313 have u check my answer –Dixit Patel Jan 19 '13 at 5:15 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted this is the solution for you According to documentation and my experience i
2340: Unable to prevent WebView from displaying error page 36 people starred this issue and may be notified of changes. Back to list Status: Obsolete Owner: cccandr...@gmail.com Closed: Dec 2014 Type-Enhancement Priority-Medium Component-Browser Sign in to add a comment Reported by jaya...@gmail.com, Mar 31, 2009 The WebViewClient class lets activities receive an onReceivedError callback when the WebView is unable to load a URL (e.g. because the webserver is down). An activity should be able to customize the user experience in such situations. For example, it may want to display an alert, but leave the previous page visible on the screen. The WebView in Android 1.1 does not not allow such a user experience. It will always display an error page (resource res/assets/webkit/loaderror.html). Steps to reproduce: * Create an Activity that displays a WebView * Install a WebViewClient to the WebView * Cause the WebView to load a URL that doesn't respond, e.g. by webview.loadUrl(), or having the user click on an HTML link Observed behavior: * The WebView calls WebViewClient.onReceivedError() * The WebView displays the standard Android error page Expected correct behavior: * The WebView calls WebViewClient.onReceivedError() * The WebView content does not change Mar 31, 2009 #1 jbq+legacy@google.com (No comment was entered for this change.) Labels: -Type-Defect Type-Enhancement Aug 19, 2009 #2 cccandr...@gmail.com (No comment was entered for this change.) Status: Assigned Owner: c...@android.com Labels: Component-Browser Aug 22, 2009 #3 AndrewJa...@gmail.com One possible workaround would be to call goBack() on the WebView within onReceivedError, to return to the page being displayed before the error. However, this may not be satisfactory in all cases (eg, dynamic pages, HTML forms filled by the user), and it's a hack that shouldn't be required. +1 Aug 24, 2009 #4 cccandr...@gmail.com assigned to an engineer for review Status: Reviewed Nov 20, 2009 #5 bayeeb...@gmail.com I used loadData() to load my customized error page in onReceivedError(), but the default error page still flash out for a second. Dec 17, 2009 #6 jdand...@gmail.com Greetings! Here's my workaround: 1. I have a "curtain" view on-hand. This view is positioned above the WebView, z-order-wise. 2. I also track the WebView's errorCode (if any). By default, it is set to 0. 3. At the outset, we are showing the curtain. We then load our page. 4. For onPageFinished,