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?
解决方案:
把AlertDialog里面的context:xxxActivity.this 改为::“xxxActivity.this..getParent()”就搞定!
本文详细介绍了在Android开发过程中遇到的一个常见问题:使用AlertDialog时出现的BadTokenException错误。通过将AlertDialog内部的上下文从当前Activity修改为父级Activity,成功解决了该问题。此解决方案适用于需要在特定场景下使用AlertDialog的情况。
832

被折叠的 条评论
为什么被折叠?



