Anroid 异常:is not valid; is your activity running?
2014-11-07 17:35
513 查看
本文转载于:http://blog.csdn.net/biangren/article/details/7514722
是由于有activity时依附于另一个activity的,当被依附的activity产生错误的时候,该activity没有了靠山而产生错误(或者是调用了一个已经被finish()的activity)。一般在创建alertdialog.builder是很容易见到。
对于这个错误还没有根本的解决办法,唯一的办法就是改变该activity依附于另一activity的事实,将其放入另一activity。
Android利用ActivityGroup加载子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是稳定存在的,所以有下面的解决办法。
解决办法:
将content替换为getParent()即可。
是由于有activity时依附于另一个activity的,当被依附的activity产生错误的时候,该activity没有了靠山而产生错误(或者是调用了一个已经被finish()的activity)。一般在创建alertdialog.builder是很容易见到。
对于这个错误还没有根本的解决办法,唯一的办法就是改变该activity依附于另一activity的事实,将其放入另一activity。
Android利用ActivityGroup加载子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是稳定存在的,所以有下面的解决办法。
解决办法:
将content替换为getParent()即可。
相关文章推荐
- 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?
- 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 异常: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?
- popupwindow使用之异常-Unable to add window -- token null is not valid; is your activity running?
- Android运行异常一:token android.os.BinderProxy@438e7108 is not valid; is your activity running?
- 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?
- 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? -
- Unable to add window — token android.os.BinderProxy is not valid; is your activity running?
- unable to add window -- token null is not valid; is your activity running 错误解决办法
- Unable to add window -- token null is not valid; is your activity running?
- Unable to add window is not valid; is your activity running?