一些错误

来源:互联网 发布:java框架相关的书籍 编辑:程序博客网 时间:2024/06/08 18:57

报错一关于Unable to add window -- token null is not for an application 的错误:

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()

报错二:
Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
context 不能启动Acitvity 增加    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

原创粉丝点击