这是因为在new Dialog(context);的时候传入的context是通过getApplicationContext()获得的,这样就会报错。

把context的获得方式改为MainActivity.this就好了。

自定义对话框 提示:Unable to add window token null is not for an application的更多相关文章

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

      原博客地址:http://aijiawang-126-com.javaeye.com/blog/662336 在Activity中newSpinner是我把mContext传入,但是出了 andr ...

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

    在广播中启动一个Dialog时出现如下错误信息:Caused by: android.view.WindowManager$BadTokenException: Unable to add windo ...

  3. Unable to add window -- token null is not for an application错误的解决方法 android开发

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

  4. Android自用-----WindowManager$BadTokenException: Unable to add window -- token null is not for an application

    转自http://www.cnblogs.com/oakpip/archive/2011/04/06/2007310.html 错误产生: private Context mcontext; @Ove ...

  5. Unable to add window -- token null is not for an application

    导致报这个错是在于new AlertDialog.Builder(mcontext),虽然这里的参数是AlertDialog.Builder(Context context)但我们不能使用getApp ...

  6. android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an applic

    之前遇到过这样的问题, 04-12 10:40:33.302: E/AndroidRuntime(17213): Caused by: android.view.WindowManager$BadTo ...

  7. popupwindow使用之异常:unable to add window -- token null is not valid

    使用popwindow中又碰到一个白痴问题,在此留作纪念,希望对大家有帮助 popupwindow之所以叫这个名字,肯定是要从某个地方弹出啦,但是从哪个地方呢?必须是指定一个view嘛 void an ...

  8. Activity has leaked window that was originally added -界面退出时未关闭对话框异常 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running? -

    退出Activity时弹出登录框,点击确定finish当前Activity,结果报了这个错,随后查找资料知道 原因: 是因为退出Activity时没有关闭弹出框,出现了这个错误 解决方法: 只需要在a ...

  9. bug_ _ android.view.WindowManager$BadTokenException: Unable to add window -- token

    ========4       关于android的一个常见错误:Unable to add window --token is not valid android.view.WindowManage ...

随机推荐

  1. laravel 笔记

    1.excel composer require maatwebsite/excel ~2.0.0 Maatwebsite\Excel\ExcelServiceProvider::class, 'Ex ...

  2. WPF学习03:Element Binding

    元素绑定是数据绑定的一个子集,关于数据绑定是什么,园子里有很多文章都说得非常好,在此不予详细说明. WPF实现了完善的数据绑定机制,使得元素绑定有简易的实现步骤. 本文的元素指的是WPF中的可视控件. ...

  3. MIFARE系列2《非接触卡标准》

    根据信号发送和接收方式的不同,ISO/IEC14443-3定义了TYPEA.TYPEB两种卡型.它们的不同主要在于载波的调制深度及二进制数的编码方式.从读写机具向卡传送信号时,二者是通过13.56Mh ...

  4. hdu 1496 Equations

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...

  5. postgresql 连接数

    改文件 postgresql.conf 里的 #max_connections=32 为 max_connections=1024 以及另外相应修改 share_buffer 参数. 执行SELECT ...

  6. Xcode全局断点

    1.将导航器视图切换到断点导航器视图下,也可以用快捷键Command+7一步搞定,键盘是window风格的用户Command键是win键(有微软logo),然后点击左下角的+号,选择Add Symbo ...

  7. ext4.1动态生成多个checkboxgroup(或者radiogroup),并且有toolbar操作、

    转载自:http://blog.csdn.net/zhengyuechuan/article/details/9327291 前台controller代码: Ext.define('zyc.contr ...

  8. SQL-Server数据库学习笔记-表

    1. 表及其属性 表(Table):也称实体,是存储同类型数据的集合. 列(Field):也称字段.域或属性,它构成表的架构,具体表示为一条信息中的一个属性. 行(Row):也称元组(Tuple),存 ...

  9. 1.总结---tr()和QTextCodec对象

    1. 关于Qt 中的tr()函数-------http://tscsh.blog.163.com/blog/static/200320103201310213312518/ 在论坛中漂,经常遇到有人遇 ...

  10. UISwitch swift

    // // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fa ...