当我通过WebView加载网址时,我有时会收到大量这样的消息:
10-19 19:18:38.056: ERROR/Web Console(6524):
Uncaught Error: Too much time spent in unload handler. at v8/DateExtension:1
这个错误是什么意思?
答案 0 :(得分:4)
这似乎是在webkit中的DateExtension.cpp中定义的。如果JS钩子(插入到Date.getTime中,如果设置了enableSleepDetection(true))被调用超过1000次,则抛出C ++异常。
您可能希望获取Android源代码以进一步了解它。该文件没有文档。
答案 1 :(得分:0)
我得到了同样的错误。经过一番调查,我已经解决了这个问题。 也许这段代码可以帮到你:
{
webView = (WebView) view.findViewById(R.id.transcationwebview);
progressdialog = ProgressDialog.show(mContext, "",
mContext.getString(R.string.please_wait));
progressdialog.setCancelable(true);
progressdialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
webView.stopLoading();
// webView.clearView();
}
});
webView.setWebChromeClient(new MyChromeClient());
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setLayoutAlgorithm(
WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
// view.loadUrl(url);
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
if (progressdialog != null && progressdialog.isShowing()) {
progressdialog.dismiss();
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// TODO Auto-generated method stub
}
});
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setPluginState(PluginState.ON);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setPluginsEnabled(true);
webView.setKeepScreenOn(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
}
public class MyChromeClient extends WebChromeClient {
@Override
public void onProgressChanged(WebView view, int newProgress) {
try {
if (progressdialog.isShowing()) {
progressdialog.setMessage(getString(R.string.loading)
+ newProgress + " %");
} else {
/*
* webView.stopLoading(); webView.clearView();
*/
}
} catch (Throwable e) {
e.printStackTrace();
}
}