在处理问题的时候,经常会遇到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. 解决:”ssh-keygen 不是内部或外部命令“ 的问题

    相信大家在 码云生成/添加SSH公钥的过程中遇到一个比较常见的问题, 在cmd,命令行输入 ssh-keygen -t rsa -C "xxxxx@xxxxx.com" ; xxx ...

  2. winCE 获取路径信息

    最近在做一个SAP的winCE扫描枪项目,采用C#开发,不过在获取路径是采用了常用的System.IO.Directory.GetCurrentDirectory, 并不能使用:查询后了解到winCE ...

  3. display:table的几个用法 块级子元素垂直居中

    DIV+CSS的布局已经让表格布局几乎很少用到,除非表格语义性很强的情况. display:table解决了一部分需要使用表格特性但又不需要表格语义的情况, 尤其是DIV+CSS很不方便解决的问题,比 ...

  4. P1828 香甜的黄油 (spfa)

    [题目描述] 农夫John知道每只奶牛都在各自喜欢的牧场(一个牧场不一定只有一头牛).给出各头牛在的牧场和牧场间的路线,找出使所有牛到达的路程和最短的牧场(他将把糖放在那). [题目链接] https ...

  5. ecshop 2.7 PC 微信扫描支付配置教程

    在ecshop支付过程中,有些是没有微信支付的,需要自己添加微信支付的模块,那么怎么添加呢,添加过程需要调试,本人花了很长时间才调试成功的pc微信扫描支付, 1,数据库添加微信支付方模块 2,后台设置 ...

  6. 搜索(BFS)---计算在网格中从原点到特定点的最短路径长度

    计算在网格中从原点到特定点的最短路径长度 [[1,1,0,1], [1,0,1,0], [1,1,1,1], [1,0,1,1]] 题目描述: 1表示可以经过某个地方,求解从(0,0)位置到(tr,t ...

  7. Vue.js——60分钟组件快速入门(上篇)二

    来源:https://www.cnblogs.com/keepfool/p/5625583.html 组件简介 组件系统是Vue.js其中一个重要的概念,它提供了一种抽象,让我们可以使用独立可复用的小 ...

  8. jsp页面随页面初始化加载js函数

    1 <%@ page language="java" import="java.util.*" pageEncoding="gbk"% ...

  9. Solr的学习使用之(七)Solr高级查询facet、facet.pivot简介

    以下转载自:http://hongweiyi.com/2013/03/apache-solr-facet-introduction/ 1.什么是Faceted Search Facet['fæsɪt] ...

  10. 380-Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit

    Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit Product Description The Kintex® U ...