背景:Service服务中使用WindowManager时,Android4.4使用正常,Android6.0使用应用崩溃停止运行,提示android.view.WindowManager$BadTokenException

异常原因:

可能一>build.gradle中targetSdkVersion大于等于23版本下编译,悬浮窗权限默认是关闭没有权限,在小于23版本下编译悬浮窗权限默认是开启有权限

解决办法有:

解决一>targetSdkVersion 22;修改为小于23即可

注:

当前使用的编译器是:Android Studio2.1.2

[Android]异常8-android.view.WindowManager$BadTokenException的更多相关文章

  1. Android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original

    Android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that cr ...

  2. 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 ...

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

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

  4. 关于ProgressDialog.show抛出android.view.WindowManager$BadTokenException: Unable to add window

    下午摆弄ProgressDialog,进入就抛错:android.view.WindowManager$BadTokenException: Unable to add window -- token ...

  5. android.view.WindowManager$BadTokenException: Unable to add window

    这是在加载dialog时出现的一个异常.转载地址:http://hi.baidu.com/fbdfp/item/7dea2d0ade9121813d42e23d 扔了好久的android又开始断断续续 ...

  6. 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 ...

  7. 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 ...

  8. Android 的窗口管理系统 (View, Canvas, WindowManager)

    http://blog.csdn.net/ritterliu/article/details/39295271 From漫天尘沙 在图解Android - Zygote 和 System Server ...

  9. 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 ...

随机推荐

  1. rest frame work纪念版代码

    models.py from django.db import models from pygments.lexers import get_all_lexers from pygments.styl ...

  2. 夜话JAVA设计模式之代理模式(Proxy)

    代理模式定义:为另一个对象提供一个替身或者占位符以控制对这个对象的访问.---<Head First 设计模式> 代理模式换句话说就是给某一个对象创建一个代理对象,由这个代理对象控制对原对 ...

  3. 洛谷—— P1576 最小花费

    P1576 最小花费 题目背景 题目描述 在n个人中,某些人的银行账号之间可以互相转账.这些人之间转账的手续费各不相同.给定这些人之间转账时需要从转账金额里扣除百分之几的手续费,请问A最少需要多少钱使 ...

  4. maven 本地配置

    1.安装 配置环境变量 文件路径:C:\Program Files\apache-maven-3.3.9 2.本地文件配置 setting的配置 找到文件C:\Program Files\apache ...

  5. Ubuntu 16.04安装XMind 8

    下载: http://www.xmind.net/download/linux/ 解压 sudo unzip xmind-8-update2-linux.zip -d xmind8 移动到/opt目录 ...

  6. [Vue-rx] Watch Vue.js v-models as Observable with $watchAsObservable and RxJS

    You most likely already have data or properties in your template which are controlled by third-party ...

  7. apple air装双系统(win7)

     同事买了一个apple air.用不习惯,希望再装个win7,经过多次试验,得到例如以下操作方法: 1.在MAC系统里的"有用工具"中找到"Boot Camp 助理 ...

  8. Cisco VPP(1) 简单介绍

    一.简单介绍 VPP全称Vector Packet Processing.是Cisco2002年开发的商用代码. 2016年2月11号,Linux基金会创建FD.io项目.Cisco将VPP代码的开源 ...

  9. 逆向工程之App脱壳

    http://www.cnblogs.com/ludashi/p/5725743.html iOS逆向工程之App脱壳 本篇博客以微信为例,给微信脱壳."砸壳"在iOS逆向工程中是 ...

  10. c++中读写文件操作

    读写文件这个,不常用,每次用的时候都会百度一下,每次写法还都不一样,所有总是记混.今天利用点时间总结下之前工程中用过的.以后就安照这种方法写了. 搞acmicpc的时候喜欢用freopen(),这个是 ...