标签:
错误日志
1
2
3
4
5
6
7
|
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 ) |
错误原因
错误原因是Dialog在show的时候必须要有一个activity作为窗口载体,上面的日志的意思是承载Dialog的activity已经被销毁了,不存在了
解决办法
1、在show之前加判断activity是否被销毁了
if(!isFinishing()){
dialog.show();
}
一、dialog.show()引起的android.view.WindowManager$BadTokenException错误
标签:
原文地址:http://www.cnblogs.com/leiqun123/p/4978761.html