1 anr 类型
ANR: Application Not Responding
Include 3 types:
1.1 Key Dispatching timeout ANR(5s)
The input event don’t responding in specified time which is defined in ActivityManagerService.java such as 5 second and then ANR happened. At this time the main thread must been blocked, maybe it try to do a network access such as check update or send http request in ui thread, or do database operation or do some work like image convert.
How to solve the problem? Maybe you need a dependent thread to do these time consuming work or use handler to do connection work between UI thread and other threads. And avoided the use sleep(), wait() api or synchronized methods in main thread.
1.2 Broadcast timeout ANR(10s)
The main thread can’t execute the OnReceive function on specified time such as 10s for foreground application and 20s for background application.
1.3 Service execution timeout ANR(20s)
In this case, the anr happened means that the main thread can’t execute the OnCreate or On StartCommand of Service finish in 20s
2 Main thread
include:
1). Activity:onCreate(), onResume(), onDestroy(), onKeyDown(), onClick(),etc
2). AsyncTask: onPreExecute(), onProgressUpdate(), onPostExecute(), onCancel,etc
3). Mainthread handler: handleMessage(), post*(runnable r), etc
4.) other
3 Debug SOP
I always follow the steps to debug ANR issue.
1)