Android Webview Override Error Page
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About android webview custom font Us Learn more about Stack Overflow the company Business Learn more about hiring
Android Custom Webview Class
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the android webview onreceivederror 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 Prevent WebView from displaying “web page prevent webview from displaying "web page not available" not available” up vote 60 down vote favorite 19 I have an app that makes extensive use of a WebView. When the user of this app does not have Internet connection, a page saying "web page not available" and various other text appears. Is there a way to not show this generic text in my WebView? I would like to provide my own error handling. private final
Android Webview Onreceivederror Not Called
Activity activity = this; private class MyWebViewClient extends WebViewClient public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // I need to do something like this: activity.webView.wipeOutThePage(); activity.myCustomErrorHandling(); Toast.makeText(activity, description, Toast.LENGTH_LONG).show(); } } I found out WebView->clearView doesn't actually clear the view. java android share|improve this question asked Jul 1 '11 at 18:58 JoJo 6,8722477138 2 Why don't you check the internet connection before showing the webView and if there is no internet facility available you can skip showing WebView and instead you can show an alert or toast with no internet message? –Andro Selva Jul 12 '11 at 10:03 @JoJo can you tick an answer as correct ? probably mine :P –Sherif elKhatib Aug 11 '11 at 0:29 add a comment| 12 Answers 12 active oldest votes up vote 70 down vote accepted First create your own error page in HTML and put it in your assets folder, Let's call it myerrorpage.html Then with onReceivedError: mWebView.setWebViewClient(new WebViewClient() { public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { mWebView.loadUrl("file:///android_asset/myerrorpage.html"); } }); share|improve this answer edited Nov 24 '14 at 12:47 MysticMagicϡ 16.6k84467 answered Sep 23 '11 at 0:12 SnowboardBruin 2,29
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn android webview error handling more about Stack Overflow the company Business Learn more about hiring developers or android webview webpage not available custom posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community
Android Webview Onreceivederror Deprecated
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 onReceivedError display custom error page and reload previous http://stackoverflow.com/questions/6552160/prevent-webview-from-displaying-web-page-not-available url onResume up vote 3 down vote favorite 1 We suppose that a url is already loaded (Let's call it the original url). webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { webView.loadUrl("file:///android_asset/missing.html"); } }); I have created my own error page to prevent the "web page not available message" to appear. The app must reload the webview every time it is http://stackoverflow.com/questions/13242817/android-webview-onreceivederror-display-custom-error-page-and-reload-previous-ur resumed. So i have the following lines of code: @Override protected void onResume() { super.onResume(); webView.reload(); } The problem here is that when the error page is loaded (for example when the user is not connected to the internet), and then a connection is available again and the user resumes the app, the original url is not loaded (which seems logic, the current now is missing.html). But is this a nice approach? Any suggestions for the problem? There is also a refresh button if the user wants to reload the content. Same issue here. android webview share|improve this question asked Nov 6 '12 at 0:49 Michalis Daniilakis 198616 You might want to accept the helpful answers to some of your older questions. It'll make people more inclined to answer your newer questions. –kabuko Nov 6 '12 at 1:22 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted I'd examine internet connectivity in onResume() like suggested on http://developer.android.com/training/basics/network-ops/managing.html public static boolean isOnline() { ConnectivityManager connMgr = (ConnectivityManager) App.instans.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null && networkInfo.isConnected()); } public void onResume() { share|improve this answer answered Dec 6 '12 at 14:54 Jacob Nordfalk 2
the quirks of the universe. View my complete profile Contact @twigsama: Follow me (and my side projects) or find me online at http://twigstechtips.blogspot.com/2013/01/android-override-default-webview-error.html #genscripts hanging out with a bunch of other nerds. If you've found one or more of my blog posts helpful, why not say thanks by buying me a coffee or beer? https://groups.google.com/d/topic/android-developers/_teG2LGN6Ns My Pet Projects ThatAwesomeShirt! Diablo II Runewords (Android app) Code Peeker (Android app) Moustachify Everything (Android app) Slowpoke Blitz! (Android game) Fine Food (Android app) Diablo 3 Max Stats (Android app) android webview Windows 7: Remove Explorer Breadcrumbs Windows 7: Show "All Programs" in Start Menu Automatically Links chmod644 Mattoc IM.NJS peevo yuggles DCX Labels .net (3) 3ds (1) acdsee (2) acma (2) acrobat (6) adblock (1) adobe (7) analytics (1) android (138) apache (4) apple (5) ati (6) atomic bomberman (1) australia (4) bash (10) batch (3) belkin (1) billion (1) Blizzard (1) blogger (5) android webview onreceivederror Bonjour (1) bulletstorm (2) C# (4) C++ (17) canon (1) car (2) child pornography (3) cmder (1) conemu (1) cpanel (1) css (8) daemon tools (1) dd-wrt (2) dell (6) diablo 2 (2) diablo 3 (2) digg (1) digsby (1) disable (4) disqus (3) django (96) dos (4) drupal (17) dual action (1) dyndns (1) e5823 (1) eclipse (20) eee pc (2) emulation (1) esi (2) eventghost (1) excel (4) expandrive (2) facebook (17) firefox (38) flash (1) flickr (1) freedns (1) ftp (3) funny (7) genymotion (1) git (20) github (3) gmail (1) google plus (1) greasemonkey (2) hackintosh (1) harddrive (5) hardware (11) honda jazz (1) hotmail (1) hp (1) html (3) htpc (3) https (1) internet censorship (5) internet explorer (7) java (7) javascript (22) jquery (18) jquery ui (2) kodi (3) left 4 dead 2 (2) linux (35) logic (2) logitech (2) Lotus Notes (5) m1330 (4) mac osx (4) malware (7) map network drive (1) Marvel Ultimate Alliance (1) maven (6) megaman x7 (1) microsoft security essentials (1) migrate (1) miphone manager (1) mirc (2) miui (1) mobile development (2) mootoo
from GoogleSign inHidden fieldsSearch for groups or messages