【发布时间】:2013-05-12 03:41:34
【问题描述】:
我有一个使用 webview 来显示 Google App Engine 网络应用程序的 android 应用程序。如何覆盖我的应用中遇到的默认HTTP Error 504 Gateway timeout?
HTTP Error 504 Gateway timeout
The server, while acting as a gateway or proxy, did not receive a
timely response from the upstream server it accessed in attempting
to complete the request.
我已经覆盖了onReceivedError,它在没有可用的互联网连接和其他错误时工作。
webView.setWebViewClient(new WebViewClient(){
...
@SuppressLint("DefaultLocale")
@Override
public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {
try {
String template = streamToString(getAssets().open("html/error.html"));
String data = template.replaceAll("%DESCRIPTION%", description.toLowerCase())
.replaceAll("%WEBSITE_URL%", WEBSITE_URL);
view.loadDataWithBaseURL("file:///android_asset/html/", data, "text/html", "utf-8", null);
} catch (IOException e) {
e.printStackTrace();
}
}
});
onReceivedError 接收不到 HTTP 错误只有网络错误?任何解决方法? android webview如何拦截HTTP错误?
【问题讨论】:
标签: android google-app-engine error-handling android-webview