在我的 android logcat 日志中,我看到:
01-02 02:01:46.523 E/ActivityManager( 459): ANR in com.android.phone (com.android.phone/.InCallScreen)
然后当我转到 /data/anr/traces.txt 时,我看到了
Cmd line: com.android.phone
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x410f7508 self=0x40eeeb68
| sysTid=649 nice=0 sched=0/0 cgrp=apps handle=1075429168
| schedstat=( 0 0 0 ) utm=1361 stm=314 core=1
#00 pc 0000dac0 /system/lib/libc.so (epoll_wait+12)
#01 pc 00014899 /system/lib/libutils.so (android::Looper::pollInner(int)+96)
#02 pc 00014b01 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+104)
#03 pc 00063aeb /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#04 pc 0001df30 /system/lib/libdvm.so (dvmPlatformInvoke+112)
#05 pc 0004d1fb /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+394)
#06 pc 00038f4d /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+8)
#07 pc 00000214 /dev/ashmem/dalvik-jit-code-cache (deleted)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:125)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
我的问题是为什么当堆栈跟踪显示 Looper 中的主线程等待消息时,android 认为应用程序处于 ANR 中?这对我来说似乎很正常。我了解当主线程正在下载某些东西/进行长时间操作时,android 会显示 ANR。但它正在等待消息似乎很正常。如果我错了,请纠正我。