Android开发遇到这个错误:
ERROR/AndroidRuntime(247): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
原因:
在传context的时候用了getApplicationContext()
解决办法
传context的时候使用Activity.this
本文详细解析了在Android开发过程中遇到的WindowManager$BadTokenException异常的原因,并提供了有效的解决方法,即在传入Context时使用Activity.this而非getApplicationContext()。
Android开发遇到这个错误:
ERROR/AndroidRuntime(247): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
原因:
在传context的时候用了getApplicationContext()
解决办法
传context的时候使用Activity.this

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