ANR错误 - 屏幕关闭 - 我该如何处理它们?

时间:2011-11-10 15:54:25

标签: android freeze android-anr-dialog

我在开发者控制台上收到此消息,指出我的应用程序已冻结,因为:

ANR意向广播{act = android.intent.action.SCREEN_OFF flg = 0x40000000}

没有堆栈跟踪,因为这是由前Froyo用户引发的。它甚至没有告诉我应用程序中的哪个活动导致了错误 - 尽管我猜这是我的游戏活动。

这也符合我自己的经验,有时当我的手机电池电量不足时,我的应用程序会冻结并且必须被杀死。

我应该在我的活动中做些什么来处理这个冻结状态?

我现在从市场上得到了一些适当的输出,但我仍然不知道如何处理它。

DALVIK THREADS:
"main" prio=5 tid=1 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x400227b0 self=0xce98
  | sysTid=4060 nice=0 sched=0/0 cgrp=default handle=-1345013476
  | schedstat=( 72099976000 6131816000 28732 )
  at android.media.SoundPool.play(Native Method)
  at com.bazsoft.yaniv.SoundManager.playSound(SoundManager.java:88)
  at com.bazsoft.yaniv.YanivGameActivity.displayPileCards(YanivGameActivity.java:675)
  at com.bazsoft.yaniv.YanivGameActivity.access$22(YanivGameActivity.java:659)
  at com.bazsoft.yaniv.YanivGameActivity$1.run(YanivGameActivity.java:628)
  at android.app.Activity.runOnUiThread(Activity.java:3713)
  at com.bazsoft.yaniv.YanivGameActivity.displayCards(YanivGameActivity.java:615)
  at com.bazsoft.yaniv.YanivGameActivity.access$6(YanivGameActivity.java:614)
  at com.bazsoft.yaniv.YanivGameActivity$ComputerHandler.handleMessage(YanivGameActivity.java:121)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:143)
  at android.app.ActivityThread.main(ActivityThread.java:4701)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:859)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617)
  at dalvik.system.NativeStart.main(Native Method)

"AsyncTask #5" prio=5 tid=19 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464cbd98 self=0x47f208
  | sysTid=4877 nice=10 sched=0/0 cgrp=default handle=4216856
  | schedstat=( 13501000 72691000 93 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x4648bbd0> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at  java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"AsyncTask #4" prio=5 tid=22 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x465379d8 self=0x460698
  | sysTid=4796 nice=10 sched=0/0 cgrp=default handle=4864896
  | schedstat=( 14816000 60081000 94 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46491a40> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"AsyncTask #3" prio=5 tid=21 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x46558de8 self=0x44f1a8
  | sysTid=4759 nice=10 sched=0/0 cgrp=default handle=4865256
  | schedstat=( 17781000 122763000 125 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46545340> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"Binder Thread #3" prio=5 tid=20 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x463e9610 self=0x4958e8
  | sysTid=4750 nice=0 sched=0/0 cgrp=default handle=4807336
  | schedstat=( 8851000 15266000 40 )
  at dalvik.system.NativeStart.run(Native Method)

"AsyncTask #2" prio=5 tid=18 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464423c8 self=0x48dad8
  | sysTid=4737 nice=10 sched=0/0 cgrp=default handle=3804272
  | schedstat=( 14045000 80530000 96 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x464c2db8> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"AsyncTask #1" prio=5 tid=8 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464dfed8 self=0x41b5e8
  | sysTid=4550 nice=10 sched=0/0 cgrp=default handle=3585048
  | schedstat=( 12129000 58868000 77 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x464eefa0> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  at java.lang.Thread.run(Thread.java:1096)

"WebViewWorkerThread" prio=5 tid=17 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x4644d988 self=0x32d200
  | sysTid=4099 nice=1 sched=0/0 cgrp=default handle=3330880
  | schedstat=( 74615000 42294000 225 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x4644dbc8> (a android.os.MessageQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.os.MessageQueue.next(MessageQueue.java:146)
  at android.os.Looper.loop(Looper.java:123)
  at android.os.HandlerThread.run(HandlerThread.java:60)

"http3" prio=5 tid=16 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x46438aa8 self=0x32c618
  | sysTid=4098 nice=1 sched=0/0 cgrp=default handle=3327832
  | schedstat=( 9630000 2435000 22 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46437ce8> (a android.net.http.RequestQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http2" prio=5 tid=15 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464388b8 self=0x32bbd0
  | sysTid=4097 nice=1 sched=0/0 cgrp=default handle=3325200
  | schedstat=( 6453000 547000 21 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46437ce8> (a android.net.http.RequestQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http1" prio=5 tid=14 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464386c8 self=0x32afb0
  | sysTid=4095 nice=1 sched=0/0 cgrp=default handle=3322096
  | schedstat=( 14060000 4044000 35 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46437ce8> (a android.net.http.RequestQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"http0" prio=5 tid=11 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x464384d8 self=0x31b898
  | sysTid=4094 nice=1 sched=0/0 cgrp=default handle=3263064
  | schedstat=( 10561000 11218000 28 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x46437ce8> (a android.net.http.RequestQueue)
  at java.lang.Object.wait(Object.java:288)
  at android.net.http.ConnectionThread.run(ConnectionThread.java:98)

"SoundPool" prio=5 tid=13 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x464237e0 self=0x2e4a08
  | sysTid=4077 nice=0 sched=0/0 cgrp=default handle=2519808
  | schedstat=( 236000 6104000 5 )
  at dalvik.system.NativeStart.run(Native Method)

"SoundPoolThread" prio=5 tid=12 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x46418800 self=0x2def70
  | sysTid=4078 nice=0 sched=0/0 cgrp=default handle=2520264
  | schedstat=( 4442000 4642000 55 )
  at dalvik.system.NativeStart.run(Native Method)

"pool-1-thread-1" prio=5 tid=10 WAIT 
  | group="main" sCount=1 dsCount=0 obj=0x463f2218 self=0x2ca760
  | sysTid=4075 nice=0 sched=0/0 cgrp=default handle=2878472
  | schedstat=( 86256000 83712000 143 )
  at java.lang.Object.wait(Native Method)
  - waiting on <0x463f2488> (a java.lang.VMThread)
  at java.lang.Thread.parkFor(Thread.java:1535)
  at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
  at sun.misc.Unsafe.park(Unsafe.java:317)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
  at java.uti...

1 个答案:

答案 0 :(得分:2)

Android会在检测到以下某种情况时显示特定应用程序的ANR对话框: •在5秒内无响应输入事件(例如按键,屏幕触摸)。 •BroadcastReceiver尚未在10秒内完成执行。