在webview应用程序中放大或缩小后,在后退时崩溃

时间:2015-12-01 11:11:32

标签: android webview

我使用Webview在我的应用程序中加载url。在我按下活动按钮后放大或缩小webview后,我得到以下错误并且应用程序崩溃。

错误:

FATAL EXCEPTION: main
 java.lang.IllegalArgumentException: View not attached to window manager
    at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:655)
    at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:351)
    at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:162)
    at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:407)
    at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:179)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:153)
    at android.app.ActivityThread.main(ActivityThread.java:4987)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
    at dalvik.system.NativeStart.main(Native Method)

OnDestroy()方法的代码:

@Override
protected void onDestroy() {
    super.onDestroy();
    webView.getSettings().setBuiltInZoomControls(false);
    webView.loadUrl("");
    webView.removeAllViews();
    long timeout = ViewConfiguration.getZoomControlsTimeout();
    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            webView.destroy();
        }
    }, timeout);
}

如何解决此问题?请有人帮助我...

0 个答案:

没有答案