Unable to add window -- token android.app.LocalActivityManager$Loc

本文详细介绍了在Android开发过程中遇到的一个常见问题:使用AlertDialog时出现的BadTokenException错误。通过将AlertDialog内部的上下文从当前Activity修改为父级Activity,成功解决了该问题。此解决方案适用于需要在特定场景下使用AlertDialog的情况。
09-24 15:04:58.641: ERROR/AndroidRuntime(8666): Caused by: android.view.WindowManager$BadTokenException: Unable to add window --  token android.app.LocalActivityManager$LocalActivityRecord@4053e3a0 is not valid; is your activity running?   解决方案:



    Andrdoid用仿iphone的TabBar是用TabHost+ActivityGroup来解决的,里面用View堆栈的形式加载 Activity,在里面的Activity用AlertDialog对话框是,报异 常:“android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@983iefd89 is not valid; is your activity running? ”

把AlertDialog里面的context:xxxActivity.this 改为::“xxxActivity.this..getParent()”就搞定!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值