我遇到了一个奇怪的问题。我试图加载一个https网页,但第一次页面没有加载出来。等待60秒后,我必须再次点击按钮才能加载我的页面。我的设备是Nexus 4和Lollipop版本,但在Android 4.4和4.1的设备上也会出现这个问题。该URL并没有太多内容,只有一些Javascript和CSS文件。
日志:
I/WebViewFactory﹕ Loading com.google.android.webview version 37 (1602158-arm) (code 111201)
I/LibraryLoader﹕ Loading: webviewchromium
I/LibraryLoader﹕ Time to load native libraries: 3 ms (timestamps 5331-5334)
I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
I/LibraryLoader﹕ Expected native library version number "",actual native library version number ""
I/chromium﹕ [INFO:library_loader_hooks.cc(106)] Chromium logging enabled: level = 0, default verbosity = 0
I/BrowserStartupController﹕ Initializing chromium process, renderers=0
W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
W/chromium﹕ [WARNING:resource_bundle.cc(315)] locale_file_path.empty()
I/chromium﹕ [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=72 off=159196 len=3264
I/chromium﹕ [INFO:aw_browser_main_parts.cc(78)] Loading webviewchromium.pak from, fd:73 off:229484 len:643667
W/AudioManagerAndroid﹕ Requires BLUETOOTH permission
W/chromium﹕ [WARNING:proxy_service.cc(901)] PAC support disabled because there is no system implementation
W/chromium﹕ [WARNING:data_reduction_proxy_settings.cc(403)] SPDY proxy OFF at startup
W/art﹕ Attempt to remove local handle scope entry from IRT, ignoring
W/AwContents﹕ onDetachedFromWindow called when already detached. Ignoring
I/chromium﹕ [INFO:SkUtilsArm.cpp(179)] Device supports ARM NEON instructions!
我的代码:
final WebView wv = (WebView) alert.findViewById(R.id.modal_wv);
wv.getSettings().setAppCacheEnabled(true);
wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
wv.getSettings().setAppCachePath("/data/data/" + getPackageName() + "/cache");
wv.getSettings().setAllowFileAccess(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl(connectionResponse.getUrl());
/*
//Same behavior ...
wv.post(new Runnable() {
@Override
public void run() {
wv.loadUrl(connectionResponse.getUrl());
}
});
*/
我设置了一个新的WebClient()并覆盖了以下方法:shouldOverrideUrlLoading、onLoadResource、onPageFinished。为了测试目的,我移除了这个自定义的WebClient,但第一次加载仍然无法完成。
谢谢