Unable to add window token null is not valid is your activity running
莫名其妙的报错
错误原因是不在主线程调用了弹窗方法
解决方法很简单
创建Handler
static final int REFRESH_COMPLETE = 0X1112;
private Handler mHandler = new Handler() {public void handleMessage(android.os.Message msg) {switch (msg.what) {case REFRESH_COMPLETE:ObServernotice.getInstance().notifyObserver(211,1,"",null);
//todo...在这里调用弹窗break;}}};
子线程调用mHandler
if (MainActivity.this instanceof Activity) {if ( (MainActivity.this).isFinishing()) {return ;} }
mHandler.sendEmptyMessageDelayed(REFRESH_COMPLETE, 1000);
Unable to add window token null is not valid is your activity running相关推荐
- Android --- 刚刚进入 Activity 页面的时候无法打开对话框,报错 Unable to add window -- token null is not valid; is your
报错如下: E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.gxuwz.yixin, PID: 29723java.lang.RuntimeEx ...
- Android之运行PopupWindow提示Unable to add window -- token null is not valid; is your activity running?
1.问题 在使用PopupWindow的时候,我们构建好了直接放在Activity的onCreate函数里面直接运行,提示这个错误 Unable to add window -- token null ...
- AlertDialog显示错误 Unable to add window token null is not for an application
在listView的onItemClick函数中显示一个AlertDialog,出现如下错误 08-07 21:26:43.506: ERROR/AndroidRuntime(9390): andro ...
- android Unable to add window -- token null is n...
2019独角兽企业重金招聘Python工程师标准>>> 问题的原因:调用了getApplicationContext()复制给你的context 解决方法:将activity赋值co ...
- android.view.WindowManager$BadTokenException: Unable to add window — token null
错误产生: private Context mcontext; @Override protected void onCreate(Bundle savedInstanceState) {mconte ...
- 自定义对话框 提示:Unable to add window token null is not for an application
这是因为在new Dialog(context);的时候传入的context是通过getApplicationContext()获得的,这样就会报错. 把context的获得方式改为MainActiv ...
- AlertDialog Unable to add window token null is
2019独角兽企业重金招聘Python工程师标准>>> AlertDialog.Builder参数应该是Activity而不是getApplicationContext(); 转载于 ...
- Unable to add window -- token null is not for an application
导致报这个错是在于new AlertDialog.Builder(mcontext),虽然这里的参数是AlertDialog.Builder(Context context)但我们不能使用getApp ...
- Android之Dialog提示Unable to add window -- token is not valid; is your activity running?
1.问题 Dialog奔溃提示Unable to add window -- token android.os.BinderProxy@b251dbc is not valid; is your ac ...
最新文章
- php留言板源码免mysql_PHPMYSQL留言板源码(终极完整版).doc
- ATSS EfficientDet
- Apache Thrift使用简介
- 高端技巧:怎样使用#define定义变量
- HDU 1789 Doing Homework again (贪心)
- switch 根据键盘录入成绩 显示分数及判断等级(第三次)
- python getopt模块_python之getopt模块使用
- 前端学习(805):简单数据类型和复杂数据类型
- 如何提取明细表头_如何在实际操作中应用偏移修剪?
- ROS入门 TX2+Turtlebot+Kinect2.0配置记录
- jq分页 不刷新页面_滑动无限加载和分页哪个对搜索引擎更友好呢?
- 剑指offer-从尾到头打印链表
- python安装whl_1 Matplotlib在win10下安装
- php 域名方法,PHP获取域名方法
- 利用全能电子地图下载器+GeoWebCache发布Arcgis Server缓存瓦片过程全记录
- struts2拦截器的使用及作用
- U盘存储设备有回收站吗及如何快速恢复u盘数据
- Markdown表格——在CSDN上画表格
- ICT融合和创新带来制造业的持续变革
- 最强大脑记忆曲线(10)—— 信息统计