while pop up one alert dialog in service, for sdk <=19, only required permission in manifest 

then set dialog dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

is success.

but for sdk > 23 android 6.0 ++ , it failed.

we need require permission when your app first time run, then reply permissoin 

if (!Settings.canDrawOverlays(this)) {                                Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,                        Uri.parse("package:" + getPackageName()));                this.startActivity(intent);                dialogConnectLost.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);} else {                  dialogConnectLost.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);}

BUT , another way to fix that is keep your targetSdkVersion <23, it will work as on sdk below 23. and 

you just keep old code no need change.   

no matter your buid sdk of project is >23 or not.

this is what targetSdkVersion 's magic effect.

included: build sdk >= 23 , then app could run on android 6.0++, keep target sdk < 23, then app could run like old sdk.

 

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 1、突然对jQuery的心血来潮
  2. 常用验证JS代码基础及实例
  3. 如何使函数等到对象的值未定义为js setTi
  4. 单选按钮单击,隐藏/显示不工作
  5. 无法在JQuery中查找表单输入
  6. IE中使用jquery的Google geomap失败
  7. 动态更改angularjs中静态段落的颜色
  8. javascript的密封对象之seal(),isSealed(
  9. 对多维数组中的列进行排序
  10. 如何调用另一个函数内的函数?