AlertDailog: android.view.WindowManager$BadTokenException: Unable to add window -- token null is no

来源:互联网 发布:linux文件类型有哪些 编辑:程序博客网 时间:2024/06/08 19:40

错误内容:AlertDailog:  android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

 原因:new Dialog(context)在创建Dialog时传递的context不是Context的getApplicationContext,而是Activity的context对象
解决方案:传递参数getApplicationContext()改为Activity类名.this,

 


 

0 0