1、ANR概念

2、ANR发生场景

Android开发者官网 上说到了两个原因:(1)点击按键或者触摸屏幕等输入事件在5s内没有响应;(2)10s内没有完成广播事件。如下所示:

Android will display the ANR dialog for a particular application when it detects one of the following conditions:

● No response to an input event (such as key press or screen touch events) within 5 seconds.
● A BroadcastReceiver hasn't finished executing within 10 seconds.

当时坊间给出的原因更多

(1)点击按键或者触摸屏幕等输入事件在5s内没有响应。

(2)BroadcastReceiver事件(onReceive(...)方法)在规定的时间内没有处理完(前台广播为10s,后台广播为60s)。

前台广播

将flag设置为Intent.FLAG_RECEIVER_FOREGROUND,该广播将成为前台广播。当发送广播时,会允许接收者以前台的优先级运行,有更段的时间间隔,可以减少接收延迟。如下所示:

  Intent mIntent = new Intent(string action);
mIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcast(mIntent);

后台广播

正常广播的接收者为后台优先级,即默认为后台广播,不会被自动提升。或者是将flag设置为Intent.FLAG_FROM_BACKGROUND,将Intent标识为来自后台的操作,而不是用户的交互行为。

(3)Service在规定时间内没有完成启动(前台Service为20s,后台Service为200s)。

(4)ContentProvider的publish在10s内没有完成。

最新文章

  1. 51Nod 算法马拉松21(迎新年)
  2. SharePoint 2013 入门教程之创建及修改母版页
  3. mysql的故事
  4. 使用jQuery基本过滤选择器
  5. CentOS 7.0系统安装配置图解教程
  6. 关于es6的箭头函数使用与内部this指向
  7. BZOJ1978: [BeiJing2010]取数游戏 game
  8. (php)生成指定个数的随机红包
  9. UINavigationController的横屏问题
  10. 在JBuilder8在使用ANT
  11. svn checkout The XML response contains invalid XML
  12. 【PAT】B1005 继续(3n+1)猜想
  13. mysql linux安装教程
  14. angular7 + d3 显示svg
  15. every day a practice —— morning(4)
  16. Eclipse远程连接HBase
  17. Hibernate笔记③--集合映射、组合映射、联合主键、查询案例
  18. 微信小程序从子页面退回父页面时的数据传递 wx.navigateBack()
  19. vcenter安装错误The DSN is pointing to anunspported ODBC driver...
  20. TensorFlow实现线性回归

热门文章

  1. vue的传参方式和router使用技巧
  2. Postman 使用详解
  3. 开机出现loading Operating System的解决方案
  4. iOS 支付(含支付宝、银联、微信)
  5. Android+appium +python 点击坐标tap方法的封装
  6. Android--app性能问题的总结(一)
  7. 开源方案搭建可离线的精美矢量切片地图服务-3.Mapbox个性化地图定制入门
  8. 微服务架构 - 搭建docker本地镜像仓库并提供权限校验及UI界面
  9. MIP 技术月报(4月):支持熊掌号登录;优化页面悬浮元素
  10. 描述性统计指标 - 众数 Mode