Error log
?
| 1234567 |
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@427b7270 is not valid; is your activity running? at android.view.ViewRootImpl.setView(ViewRootImpl.java:653) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149) at android.view.Window$LocalWindowManager.addView(Window.java:558) at android.app.Dialog.show(Dialog.java:316) |
Cause of error
The cause of the error is that dialog must have an activity as a window carrier at show, and the above log means that the activity that carries dialog has been destroyed and does not exist.
Solutions
1, before the show to determine whether the activity was destroyed
if (!isfinishing ()) {
Dialog.show ();
}
One, dialog.show () caused by the android.view.windowmanager$badtokenexception error