首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

关于Unable to add window - token null is not for an application 的异常

2012-07-03 
关于Unable to add window -- token null is not for an application 的错误最近在写到ProgressDialog的时

关于Unable to add window -- token null is not for an application 的错误
最近在写到ProgressDialog的时候 报错:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application。

ProgressDialog progressDialog=new ProgressDialog(context);
此处的context 要保证你的上下文要为activity对象,只有activity才能添加ProgressDialog窗体,
为了确保正确,context可以使用activity.this表示,不要一味地写成getApplicationContext()


热点排行