草庐IT

onReceivedError

全部标签

Android webview onReceivedError 显示自定义错误页面并重新加载以前的 url onResume

我们假设已经加载了一个url(我们称它为原始url)。webView.setWebViewClient(newWebViewClient(){@OverridepublicvoidonReceivedError(WebViewview,interrorCode,Stringdescription,StringfailingUrl){webView.loadUrl("file:///android_asset/missing.html");}});我创建了自己的错误页面以防止出现“网页不可用消息”。应用程序必须在每次恢复时重新加载webview。所以我有以下代码行:@Overridepr

android - WebView 客户端的 onReceivedHttpError 和 onReceivedError b/w 有什么区别

我想了解黑白的区别https://developer.android.com/reference/android/webkit/WebViewClient.htmlonRecievedHttpError和onRecievedError。对我来说,对于我网页中的所有错误,我总是会收到这两个回调?为什么我们有两个回调。 最佳答案 onReceivedError()Reportwebresourceloadingerrortothehostapplication.Theseerrorsusuallyindicateinabilitytoc

android - 如何检查 webview 是否无法加载页面(android)?

我的应用程序中有一个webview,但有时由于连接性,webview无法加载,我得到默认网页不可用页面。如果webview加载失败,我想显示一个alertdialog。无论如何我可以检查(可能在shouldOverridePageLoad函数中)webview是否成功加载?再次感谢 最佳答案 在您的WebView上使用WebClient,如下所示:webView.setWebViewClient(newWebViewClient(){@OverridepublicvoidonReceivedError(WebViewview,Web

android - 如何检查 webview 是否无法加载页面(android)?

我的应用程序中有一个webview,但有时由于连接性,webview无法加载,我得到默认网页不可用页面。如果webview加载失败,我想显示一个alertdialog。无论如何我可以检查(可能在shouldOverridePageLoad函数中)webview是否成功加载?再次感谢 最佳答案 在您的WebView上使用WebClient,如下所示:webView.setWebViewClient(newWebViewClient(){@OverridepublicvoidonReceivedError(WebViewview,Web

Android WebView onReceivedError()

有没有人知道有没有办法在WebView中拦截“页面未找到”或“页面未加载错误”?根据android文档,onReceivedError()应该可以拦截。但我在一个应用程序中测试了它,我故意给出了错误的URL,它没有做任何事情。如果URL由于任何原因不可用,我希望我的应用能够提供我自己的自定义错误消息。这是什么都没做的代码:publicvoidonReceivedError(WebViewview,interrorCode,Stringdescription,StringfailingUrl){//customerrorhandling...showandalertortoastorso

Android WebView onReceivedError()

有没有人知道有没有办法在WebView中拦截“页面未找到”或“页面未加载错误”?根据android文档,onReceivedError()应该可以拦截。但我在一个应用程序中测试了它,我故意给出了错误的URL,它没有做任何事情。如果URL由于任何原因不可用,我希望我的应用能够提供我自己的自定义错误消息。这是什么都没做的代码:publicvoidonReceivedError(WebViewview,interrorCode,Stringdescription,StringfailingUrl){//customerrorhandling...showandalertortoastorso

Android 4.4 在 onReceivedError 中为 WebView 返回 ERR_CACHE_MISS 错误

我的布局中有一个webview。默认情况下,其中会打开一个搜索表单。在搜索时,搜索表单下方会出现一个列表部分。如果单击列表中的任何链接,则会打开详细信息页面。现在我想控制webview的后退导航。我把这段代码放在了Activity中。@OverridepublicbooleanonKeyDown(intkeyCode,KeyEventevent){Log.d("TYPE",TYPE);WebViewmyWebView=null;if(TYPE.equalsIgnoreCase("REPORT_ACTIVITY"))myWebView=reportView;if(TYPE.equalsI

Android webview onReceivedError() 不工作

我试图在我的WebView上显示一个警告框而不是“网页不可用”错误页面,但即使按照文档添加onReceivedError()方法后也无法工作,如果我遗漏了什么,请给我建议,这是我的代码...publicclassCloudPageHolderextendsActivity{WebViewmWebView;ProgressDialog_dialog;publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);mWebView=(W

android - 如何仅从 WebViewClient 的新 onReceivedError 中的主页检测错误

上下文在AndroidSDK23中onReceivedError(WebViewview,interrorCode,Stringdescription,StringfailingUrl)已被弃用并替换为onReceivedError(WebViewview,WebResourceRequestrequest,WebResourceErrorerror)。然而根据documentation:Notethatunlikethedeprecatedversionofthecallback,thenewversionwillbecalledforanyresource(iframe,image

Android WebViewClient onReceivedError 没有调用 404 错误

嗨在ListView中,我有一个webview,它应该从服务器加载图像文件,当没有图像时,我需要一个虚拟图像。我试过了holder.image.setWebViewClient(newWebViewClient(){@OverridepublicvoidonReceivedError(WebViewview,interrorCode,Stringdescription,StringfailingUrl){System.out.println("descriptionerror"+description);view.setVisibility(View.GONE);}@Overridep
12