android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an appli

来源:互联网 发布:网络丑男图片 编辑:程序博客网 时间:2024/05/17 07:22

Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

解决

1.我的mProgressDialog是在线程里的通过Handle去更新,消息不会是null;

2.开始怀疑context对象的问题,将context由activity提升是application,现象还是一样。

3.怀疑view,应该是windowManager.layoutParams中应该缺少什么参数,没错,windowManager.layoutParams中不能没有type的参数,添加mProgressDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 

程序正常运行!!!