标签:
判断一下Activity是否在finishing就好了,否则万一Activity销毁了,这个Dialog没有所依附的对象,就会有下面的异常抛出
private Handler myHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case DISPLAY_DLG: if (!isFinishing()) { showDialog(MY_DIALOG); } break; } } };
android.view.WindowManager$BadTokenException: Unable to add window — token android.os.BinderProxy@447a6748 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:468)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:239)
at android.app.Activity.showDialog(Activity.java:2488)
…
at android.os.Handler.dispatchMessage(Handler.java:99)
…
Activity中异步操作showDialog异常解决方法:判断Ay是否结束
标签:
原文地址:http://www.cnblogs.com/permanent2012moira/p/5007833.html