我有一个在webview上运行jquery mobile的网站。当活动开始时一切正常,但是在活动暂停30分钟或更长时间之后我又回到webview,它就不再起作用了。看起来JavaScript停止响应。
我正在使用web.load(url)方法加载网页。
@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
private void initUI(View view)
{
logger.info("initUI() - Initilazing Fragment UI");
webViewPlaceholder = ((FrameLayout)view.findViewById(R.id.webViewPlaceholder));
if (webView == null)
{
logger.info("initUI() - Creating WebView");
webView = new WebView(this.getActivity());
FrameLayout.LayoutParams layoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT);
webView.setLayoutParams(layoutParameters);
webView.addJavascriptInterface(new JavascriptUtils(this.getActivity()), "Android");
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(false);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
if (Build.VERSION.SDK_INT >= 11){
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(SeeWhatYouLikeWebClientFactory.getWebClient(this));
webView.setWebChromeClient(new SWYLWebChromeClient());
}
// Attach the WebView to its placeholder
webViewPlaceholder.addView(webView);
}
由于