android View not attached to window manager

java.lang.IllegalArgumentException: View=com.android.internal.policy.impl.PhoneWindow$DecorView{4234dd70 V.E..... R.....ID 0,0-263,210} not attached to window manager
	at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:389)
	at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:318)
	at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
	at android.app.Dialog.dismissDialog(Dialog.java:332)
	at android.app.Dialog.dismiss(Dialog.java:315)


发生上述的错误,原因是因为Activity关闭了,然后Dialog执行了dismiss方法。

if (null != progressDialog && progressDialog.isShowing()) {// 隐藏加载框
    progressDialog.dismiss();
}
一般这种情况发生在Handler回调的接口。


解决方案在onPause()方法里面dissmiss:

        @Override
	    public void onPause() {
	    super.onPause();
            if ((null != progressDialog) && progressDialog.isShowing()) {
	        progressDialog.dismiss();
	    }
	    progressDialog = null;
	}


http://stackoverflow.com/questions/2224676/android-view-not-attached-to-window-manager?lq=1



你可能感兴趣的:(android View not attached to window manager)