由于某些原因需要在该activity的onDestroy方法里面调用webView.destroy()。当进入该webview并且进行缩放操作时,退出该activity程序崩溃。
找到三种方式:
第一种:web.setVisibility(View.GONE);把WebView设置为GONE就可以了。
第二种:延迟destroy webview
@Override
protected void onDestroy() {
/* if(webview!=null) {
webview.setVisibility(View.GONE);
webview.removeAllViews();
webview.destroy();
releaseAllWebViewCallback();
}*/
if(webview != null) {
webview.getSettings().setBuiltInZoomControls(true);
webview.setVisibility(View.GONE);
long timeout = ViewConfiguration.getZoomControlsTimeout();//timeout ==3000
Log.i("time==",timeout+"");
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
webview.destroy();
}
}, timeout);
}
super.onDestroy();
}
第三种:也是最直接有效的,禁用。
webview使用settings.setBuiltInZoomControls(false);//禁止进行控制缩放