ITeye博客

Dialog 出现的android.view.WindowManager$BadTokenException: Unable to add window异常

mfan · 2012-09-11 01:54 · Android · 移动开发 · Markdown

Dialog异常:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

异常原因:
new AlertDialog.Builder(Context context)中的参数不能用getApplicationContext()获得的context,而必须使用Activity,因为只有一个Activity才能添加一个窗体。

解决办法:
例如 new AlertDialog.Builder(XXXActivity.this)

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。