android报错——Unable to add window -- token null is not for an application
来源:互联网 发布:地税局数据采集手续 编辑:程序博客网 时间:2024/05/16 15:08
这个问题出现在我在一个activity中创建dialog的时候。
注意最开始的时候,尽管方法是这样的
public Builder(Context context) {
this(context, resolveDialogTheme(context, 0));
}
但是由于这里是要弹出一个对话框,所以这里的参数不能是上下文对象,而是一个活动对象,改成**Activity.this 就可以了。
AlertDialog.Builder builder=new AlertDialog.Builder(MainActivity.this);
builder.setTitle("确认手机号")
.setMessage("我们将发送验证码短信到这个号码"+code+phone)
.setPositiveButton("好的", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
SMSSDK.getVerificationCode(code,phone.trim());
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
et_phoneNum.setText("");
dialog.dismiss();
}
});
builder.create().show();
报错解决参考http://www.cnblogs.com/oakpip/archive/2011/04/06/2007310.html
0 0
- android报错——Unable to add window -- token null is not for an application
- Dialog(四)——报错Unable to add window -- token null is not for an application
- Dialog throwing "Unable to add window — token null is not for an application” with getApplication()
- android.view.WindowManager$BadTokenException: 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
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- Android Custom Dialog错误Unable to add window -- token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- android AlertDialog显示错误 Unable to add window token null is not for an application
- android debug:Unable to add window -- token null is not for an application
- android Unable to add window -- token null is not for an application
- Unable to add window -- token null is not for an application错误的解决方法 android开发
- android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an applic
- android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an appli
- android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an applic
- WindowManager$BadTokenException: Unable to add window -- token null is not for an application
- Xml之pull解析
- 资产定价Model——随机变量因子
- 获取文件夹下最大的前n个文件
- 微信主界面开发知识点
- SDUT 2087 离散事件模拟-银行管理
- android报错——Unable to add window -- token null is not for an application
- Android编程之找不到布局文件
- dos和unix文件格式转换
- Light OJ 1116 Ekka Dokka
- 【HDU】-1052-Tian Ji -- The Horse Racing(贪心,双端队列)
- 文本编辑器讲解
- NSAttributedString——为Label设置富文本
- Git学习(2)
- Select()函数的介绍