Anroid 异常:is not valid; is your activity running?
2013-11-15 12:18
369 查看
我在出现这个问题的时候,纠结了好久,查起原因,是因为我的Activity的父Activity是一个TAbActivity。那么就会出现
这个activity时依附于另一个activity的,当被依附的activity产生错误的时候,该activity没有了靠山而产生错误(或者是调用了一个已经被finish()的activity)。一般在创建alertdialog.builder是很容易见到。
对于这个错误还没有根本的解决办法,唯一的办法就是改变该activity依附于另一activity的事实,将其放入另一activity。
Android利用TabActivity加载子Activity,子Activity调用对话框,弹出:
ERROR/AndroidRuntime(10104): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@45a58ee0 is not valid; is your activity running?
原因分析:
因为new对话框的时候,参数content 指定成了this,即指向当前子Activity的content。但子Activity是动态创建的,不能保证一直存在。其父Activity的content是稳定存在的,所以有下面的解决办法。
解决办法:
![](http://images.cnitblog.com/blog/450548/201311/15121644-51e6777bc9f0428d8cdc1fa0edd9f41a.jpg)
将content替换为getParent(),这样就可以动态获取了。。。
这个activity时依附于另一个activity的,当被依附的activity产生错误的时候,该activity没有了靠山而产生错误(或者是调用了一个已经被finish()的activity)。一般在创建alertdialog.builder是很容易见到。
对于这个错误还没有根本的解决办法,唯一的办法就是改变该activity依附于另一activity的事实,将其放入另一activity。
Android利用TabActivity加载子Activity,子Activity调用对话框,弹出:
ERROR/AndroidRuntime(10104): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@45a58ee0 is not valid; is your activity running?
原因分析:
因为new对话框的时候,参数content 指定成了this,即指向当前子Activity的content。但子Activity是动态创建的,不能保证一直存在。其父Activity的content是稳定存在的,所以有下面的解决办法。
解决办法:
![](http://images.cnitblog.com/blog/450548/201311/15121644-51e6777bc9f0428d8cdc1fa0edd9f41a.jpg)
将content替换为getParent(),这样就可以动态获取了。。。
相关文章推荐
- Anroid 异常:Unable to add window …… is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:Unable to add window 。。is not valid; is your activity running?
- Anroid 异常:Unable to add window …… is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Anroid 异常:is not valid; is your activity running?
- Activity has leaked window that was originally added -界面退出时未关闭对话框异常 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? -
- Anroid 异常:is not valid; is your activity runnin
- 运行异常:android.view.WindowManager$BadTokenException:is not valid; is your activity running?
- Android运行异常一:token android.os.BinderProxy@438e7108 is not valid; is your activity running?
- popupwindow使用之异常-Unable to add window -- token null is not valid; is your activity running?
- is not valid; is your activity running?异常
- 开发中碰到的问题:token null is not valid; is your activity running?
- Unable to add window — token android.os.BinderProxy is not valid; is your activity running?
- Unable to add window is not valid; is your activity running?
- BUG popupwindow的使用 token null is not valid; is your activity running?