在处理问题的时候,经常会遇到ANR,停止运行等问题,经过分析和验证,和如下的一行关键log有关

WindowManager: Adding more than one toast window for UID at a time.

这一行log对应的代码如下:

 // If adding a toast requires a token for this app we always schedule hiding
// toast windows to make sure they don't stick around longer then necessary.
// We hide instead of remove such windows as apps aren't prepared to handle
// windows being removed under them.
//
// If the app is older it can add toasts without a token and hence overlay
// other apps. To be maximally compatible with these apps we will hide the
// window after the toast timeout only if the focused window is from another
// UID, otherwise we allow unlimited duration. When a UID looses focus we
// schedule hiding all of its toast windows.
if (type == TYPE_TOAST) {
if (!getDefaultDisplayContentLocked().canAddToastWindowForUid(callingUid)) {
Slog.w(TAG_WM, "Adding more than one toast window for UID at a time.");
return WindowManagerGlobal.ADD_DUPLICATE_ADD;
}
// Make sure this happens before we moved focus as one can make the
// toast focusable to force it not being hidden after the timeout.
// Focusable toasts are always timed out to prevent a focused app to
// show a focusable toasts while it has focus which will be kept on
// the screen after the activity goes away.
if (addToastWindowRequiresToken
|| (attrs.flags & LayoutParams.FLAG_NOT_FOCUSABLE) == 0
|| mCurrentFocus == null
|| mCurrentFocus.mOwnerUid != callingUid) {
mH.sendMessageDelayed(
mH.obtainMessage(H.WINDOW_HIDE_TIMEOUT, win),
win.mAttrs.hideTimeoutMilliseconds);
}
}

此段代码在WindowManagerService.java中的addWindow函数,可以对比android源码,只有android7.1才会有这段代码,即只有android7.1对toast类型的窗口有限制。

那么这个限制导致到底是什么呢?

可以查看如下修改说明:

https://android.googlesource.com/platform/frameworks/base/+/dc24f93%5E%21/#F6

修改的目的:

Prevent apps to overlay other apps via toast windows

It was possible for apps to put toast type windows that overlay other apps which toast winodws aren't removed after a timeout.

Android7.1后对于Toast类型窗口的限制的更多相关文章

  1. 交叉报表列头排序时遇到的oracle问题—oracle ORA-12704:字符集不匹配、varchar2转化为nvarchar2字符缺失、case when else后的字符类型要一致

    在做交叉报表列头的排序时,遇到这三个问题,下面具体来说一下. 设计的数据库的表结构如图1所示: 图1 要处出来student_name_,s.grade_,s.subject_name_,这三个属性, ...

  2. 启动Jmeter4.0 后弹出命令窗口提示信息是什么意思?

    启动Jmeter4.0 后弹出命令窗口提示信息: =========================================================================== ...

  3. ASPX 关闭子窗口后自动更新父窗口

    Response.Write("<script language:javascript>javascript:window.close();</script>&quo ...

  4. Android7.0后JNI库必须保留Section Headers

    此修改在官网的描述如下: Each ELF file has additional information contained in the section headers. These header ...

  5. easyUI dialog打开对话框,显示列表数据,选取一条数据操作后赋值给父窗口 resultMap声明为全局,生成getset方法

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" ...

  6. JS实现单击按钮后弹出新的窗口页面

    点击按钮后,弹出指定大小的页面窗口. 效果图: 源码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

  7. C# winForm 窗口跳转后关闭上一个窗口的方法

    FrmMain main = new FrmMain(); main.Owner = this; this.Hide(); main.ShowDialog(); Application.ExitThr ...

  8. emwin 解决在A窗口上新建B窗口后‘只激活’B窗口问题

    @2018-08-08 问题来源: 要实现A窗口上的参数修改,通过A窗口上新建的B窗口小键盘实现数据录入,但结果是只要点击A窗口上的任何地方(包括B窗口上的任意位置),则B窗口就消失了 解决办法: 使 ...

  9. DataGridView 绑定数据后修改列类型

    dataGridView1.DataSource = dt; dataGridView1.Columns.RemoveAt(); //删除要被替换的列 DataGridViewLinkColumn l ...

随机推荐

  1. CDH平台搭建解决离线安装依赖包的方法

    背景介绍: 1CDH开发平台在搭建的过程中,会遇到各种各样的问题,其中的各种依赖就是一个很让人头痛的问题.如果安装脚本文件出现了这种问题,那么就可以把以下的这种方法加入shell中,但是不要用yum来 ...

  2. [Web 前端] 019 css 定位之绝对定位与相对定位

    1. 关于定位 我们可以使用 css 的 position 属性来设置元素的定位类型 postion 的设置项如下 设置项 释义 relative 生成相对定位元素元素所占据的文档流的位置不变元素本身 ...

  3. framebuffer设备驱动分析

    一.设备驱动相关文件 1.1. 驱动框架相关文件 1.1.1. drivers/video/fbmem.c a. 创建graphics类.注册FB的字符设备驱动 fbmem_init(void) { ...

  4. Mysql 数据库存储的原理??

    储存过程是一个可编程的函数,它在数据库中创建并保存.它可以有 SQL 语句和一些特殊的控制结 构组成.当希望在不同的应用程序或平台上执行相同的函数,或者封装特定功能时,存储过程是非常有用的.数据库中的 ...

  5. C# EF优化

    原文:https://www.cnblogs.com/wangyuliang/p/10338902.html   https://www.cnblogs.com/simadi/p/6879366.ht ...

  6. 2018-8-27-C#-powshell-调用

    title author date CreateTime categories C# powshell 调用 lindexi 2018-8-27 16:20:4 +0800 2018-06-18 20 ...

  7. linux 配置 Sersync

    [root@SERSYNC sersync]# cp conf/confxml.xml conf/confxml.xml.bak.$(date +%F) [root@SERSYNC sersync]# ...

  8. VMware新加网卡NAT连接(内网)出现本机与虚拟机ping不通的问题

    今新加网卡NAT连接,配置好之后始终出现eth1:link is not ready. 虚拟机与本机不能建立连接. 解决方案:windows里面打开服务开启VMware NAT Service,并关闭 ...

  9. powerdesigner数据库设计

    (1)创建物理数据模型 打开PowerDesigner,然后点击File-->New  Model然后选择如下图所示的物理数据模型(物理数据模型的名字自己起,然后选择自己所使用的数据库即可) ( ...

  10. C#.Net 调用Java的Web Service

    首先,得有一个web service地址:http://www.baiduc.om/XXServices?wsdl 然后在.net 项目中添加Web引用,并把地址给它输进去 第三.编码: using ...