Android7.1后对于Toast类型窗口的限制
在处理问题的时候,经常会遇到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类型窗口的限制的更多相关文章
- 交叉报表列头排序时遇到的oracle问题—oracle ORA-12704:字符集不匹配、varchar2转化为nvarchar2字符缺失、case when else后的字符类型要一致
在做交叉报表列头的排序时,遇到这三个问题,下面具体来说一下. 设计的数据库的表结构如图1所示: 图1 要处出来student_name_,s.grade_,s.subject_name_,这三个属性, ...
- 启动Jmeter4.0 后弹出命令窗口提示信息是什么意思?
启动Jmeter4.0 后弹出命令窗口提示信息: =========================================================================== ...
- ASPX 关闭子窗口后自动更新父窗口
Response.Write("<script language:javascript>javascript:window.close();</script>&quo ...
- Android7.0后JNI库必须保留Section Headers
此修改在官网的描述如下: Each ELF file has additional information contained in the section headers. These header ...
- easyUI dialog打开对话框,显示列表数据,选取一条数据操作后赋值给父窗口 resultMap声明为全局,生成getset方法
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" ...
- JS实现单击按钮后弹出新的窗口页面
点击按钮后,弹出指定大小的页面窗口. 效果图: 源码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...
- C# winForm 窗口跳转后关闭上一个窗口的方法
FrmMain main = new FrmMain(); main.Owner = this; this.Hide(); main.ShowDialog(); Application.ExitThr ...
- emwin 解决在A窗口上新建B窗口后‘只激活’B窗口问题
@2018-08-08 问题来源: 要实现A窗口上的参数修改,通过A窗口上新建的B窗口小键盘实现数据录入,但结果是只要点击A窗口上的任何地方(包括B窗口上的任意位置),则B窗口就消失了 解决办法: 使 ...
- DataGridView 绑定数据后修改列类型
dataGridView1.DataSource = dt; dataGridView1.Columns.RemoveAt(); //删除要被替换的列 DataGridViewLinkColumn l ...
随机推荐
- vue中的computed 与 watch
计算属性 computed 指通过计算得来的属性,用于监听属性的变化 computed里面的函数调用的时候 不需要加() 方法里必须有一个返回值 return computed中的函数不会通过事件去触 ...
- NoSQL基础学习
NoSQL基础学习 最近学习的第一个Nosql就是Mongodb,为了了解Nosql的基本知识,特地总结,主要是学习Nosql的理论 一.Introduction(介绍) 它是“ Not Only S ...
- linux中cut命令
cut命令 cut常用参数 cut命令用来显示行中的指定部分,删除文件中指定字段. 说明:该命令有两项功能,其一是用来显示文件的内容,它依次读取由参数file所指明的文件,将它们的内容输出到标准输出上 ...
- FastDFS搭建单机图片服务器(二)
防丢失转载:https://blog.csdn.net/MissEel/article/details/80856194 根据 分布式文件系统 - FastDFS 在 CentOS 下配置安装部署 和 ...
- python 合并字典/拼接字典
针对于python 3.5以上版本: 最好的最快的最优雅的方法是: result_dict = {**dict_1, **dict_2} 例如:( dict 代表 dictionary,也就是字典) ...
- Redis 和 MongoDB 的优缺点??
MongoDB 和 Redis 都是 NoSQL,采用结构型数据存储.二者在使用场景中,存在一定的区别, 这也主要由于二者在内存映射的处理过程,持久化的处理方法不同.MongoDB 建议集群部署,更多 ...
- 封装RF keyword
*** Settings ***Library SeleniumLibrary *** Keywords ***打开浏览器 [Arguments] ${url} ${browser} Open Bro ...
- ASE Alpha Sprint - backend scrum 8
本次scrum于2019.11.13再sky garden进行,持续30分钟. 参与人: Zhikai Chen, Jia Ning, Hao Wang 请假: Xin Kang, Lihao Ran ...
- 如何官网下载chrome谷歌浏览器离线安装包
目录 1. 下载步骤 2. 将语言更改为中文 3. 插件 3.1. chrome 网上应用店 3.1.1. google-access-helper 4. 更新失败 1. 下载步骤 注意 需要梯子才能 ...
- idea import class的快捷键
有自动import class的快捷键 设置如下: 1.alt+enter 2.写好代码之后ctrl+alt+l格式化代码,优化导入包 1.alt+enter 2.写好代码之后ctrl+alt+l ...