项目中在webview使用了一个本地html,并使用settimeout来定时刷新画地图路线的代码。
无论我在activity的ondestory方法中调用了webview.pausetimer方法,还是webview=null都没有效果。
最后解决为:在静态页面中添加一个停止timeout的js代码,并activity的ondestory时用java代码调用该js方法
function timerStop(){ window.Demo.showToast("timerStop!"); // timer.stop(); clearTimeout(timer); }
@Override protected void onDestroy() { super.onDestroy(); isDestory=true; // webview.pauseTimers(); webview.loadUrl("javascript:timerStop()"); }
1 楼
okwangxing
2012-03-20
要是加载优酷类型的网站。怎么取消掉呢?