1、ANR介绍

2018-06-10  本文已影响0人  longshuai

ANR就是Application Not Responding

产生原因:APP阻塞了UI线程

怎么产生的:

1、AMS的回调消息产生

Application:onCreate,onTerminate等 超过5秒

Activity:onCreate,onResume,onDestory,onKeyDown,onClick等超过5秒

Service:onCreate,onStart,onDestory等超过20秒

BroadcastReceive:onReceive前台广播超过20秒,后台超过60秒

2、App自己发出的消息产生

AsyncTask:onPreExecute,onProgressUpdate,onPostExecute,onCancel等超过5秒

MainThread Handler:handleMessage,post*Runnable 等超过5秒

3、偶现ANR事件, 如何去定位呢?

可以通过命令adb pull /data/anr/traces.txt . 获取ANR堆栈日志,然后查找日志里

以DALVIK THREADS:(mutexes: tll=0 tsl=0 tscl=0 ghl=0)"main" prio=5 tid=1 NATIVE开头的日志,看下出错信息,就可以分析到ANR的原因

上一篇 下一篇

猜你喜欢

热点阅读