首先,我使用System.Out.print输出一些内容,但我没有在控制台或logcat中看到它,它在哪里显示?
然后当按下按钮时,需要很长时间才能响应。我从logcat中记录文件,并且不知道操作系统正在做什么花了这么长时间。
02-16 13:01:07.859: WARN/WindowManager(51): Key dispatching timed out sending to com.test.finalapp/com.test.finalapp.tab.FeaturedActivity
02-16 13:01:08.101: WARN/WindowManager(51): Dispatch state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to Window{44dcd868 com.test.finalapp/com.test.finalapp.MyAccount1_1Activity paused=false} @ 1329425383564
lw=Window{44dcd868 com.test.finalapp/com.test.finalapp.MyAccount1_1Activity paused=false} lb=android.os.BinderProxy@44e756f0 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{44e2b0a0 com.test.finalapp/com.test.finalapp.games.slotMachine paused=false}}}
02-16 13:01:08.119: WARN/WindowManager(51): Current state: {{null to Window{44e2c788 com.test.finalapp/com.test.finalapp.tab.FeaturedActivity paused=false} @ 1329426068120 lw=Window{44e2c788 com.test.finalapp/com.test.finalapp.tab.FeaturedActivity paused=false} lb=android.os.BinderProxy@44e2c5a0 fin=true gfw=true ed=true tts=0 wf=false fp=false mcf=Window{44e2b0a0 com.test.finalapp/com.test.finalapp.games.slotMachine paused=false}}}
02-16 13:01:08.240: INFO/ActivityManager(51): ANR in process: com.test.finalapp (last in com.test.finalapp)
02-16 13:01:08.240: INFO/ActivityManager(51): Annotation: keyDispatchingTimedOut
02-16 13:01:08.240: INFO/ActivityManager(51): CPU usage:
02-16 13:01:08.240: INFO/ActivityManager(51): Load: 0.37 / 0.37 / 0.38
02-16 13:01:08.240: INFO/ActivityManager(51): CPU usage from 8216ms to 81ms ago:
02-16 13:01:08.240: INFO/ActivityManager(51): system_server: 4% = 3% user + 1% kernel / faults: 4 minor
02-16 13:01:08.240: INFO/ActivityManager(51): obango.finalapp: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): qemud: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): logcat: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): events/0: 0% = 0% user + 0% kernel
02-16 13:01:08.240: INFO/ActivityManager(51): TOTAL: 5% = 4% user + 1% kernel
02-16 13:01:08.251: INFO/ActivityManager(51): Removing old ANR trace file from /data/anr/traces.txt
02-16 13:01:09.081: INFO/Process(51): Sending signal. PID: 239 SIG: 3
02-16 13:01:09.239: INFO/dalvikvm(239): threadid=7: reacting to signal 3
02-16 13:01:09.458: INFO/Process(51): Sending signal. PID: 51 SIG: 3
02-16 13:01:09.486: INFO/dalvikvm(51): threadid=7: reacting to signal 3
02-16 13:01:10.457: INFO/dalvikvm(239): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:12.037: INFO/dalvikvm(51): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:12.055: INFO/Process(51): Sending signal. PID: 223 SIG: 3
02-16 13:01:12.269: INFO/dalvikvm(223): threadid=7: reacting to signal 3
02-16 13:01:12.358: INFO/Process(51): Sending signal. PID: 213 SIG: 3
02-16 13:01:12.375: INFO/dalvikvm(213): threadid=7: reacting to signal 3
02-16 13:01:12.608: INFO/Process(51): Sending signal. PID: 154 SIG: 3
02-16 13:01:12.885: INFO/Process(51): Sending signal. PID: 146 SIG: 3
02-16 13:01:12.905: INFO/dalvikvm(213): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:13.113: INFO/Process(51): Sending signal. PID: 189 SIG: 3
02-16 13:01:13.348: INFO/Process(51): Sending signal. PID: 181 SIG: 3
02-16 13:01:13.602: INFO/Process(51): Sending signal. PID: 170 SIG: 3
02-16 13:01:13.816: INFO/dalvikvm(146): threadid=7: reacting to signal 3
02-16 13:01:13.976: INFO/dalvikvm(189): threadid=7: reacting to signal 3
02-16 13:01:14.084: INFO/Process(51): Sending signal. PID: 103 SIG: 3
02-16 13:01:14.144: INFO/dalvikvm(103): threadid=7: reacting to signal 3
02-16 13:01:14.342: INFO/Process(51): Sending signal. PID: 106 SIG: 3
02-16 13:01:16.950: INFO/dalvikvm(170): threadid=7: reacting to signal 3
02-16 13:01:18.814: INFO/dalvikvm(181): threadid=7: reacting to signal 3
02-16 13:01:23.204: WARN/MediaPlayer(239): info/warning (1, 44)
02-16 13:01:23.578: DEBUG/AudioSink(30): bufferCount (4) is too small and increased to 12
02-16 13:01:24.137: WARN/AudioFlinger(30): write blocked for 76 msecs, 2 delayed writes, thread 0xb388
02-16 13:01:24.385: DEBUG/dalvikvm(239): GC freed 4564 objects / 281416 bytes in 77ms
02-16 13:01:24.914: INFO/MediaPlayer(239): Info (1,44)
02-16 13:01:25.537: INFO/dalvikvm(106): threadid=7: reacting to signal 3
02-16 13:01:26.370: INFO/dalvikvm(103): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:26.435: INFO/dalvikvm(223): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:27.350: INFO/dalvikvm(170): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:27.611: INFO/dalvikvm(181): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:28.074: INFO/ActivityManager(51): Starting activity: Intent { cmp=com.test.finalapp/.Leaderboard1 (has extras) }
02-16 13:01:28.934: INFO/ActivityManager(51): Displayed activity com.test.finalapp/.Leaderboard1: 754 ms (total 754 ms)
02-16 13:01:29.889: INFO/dalvikvm(189): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:30.152: INFO/dalvikvm(146): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:30.375: INFO/dalvikvm(154): Wrote stack trace to '/data/anr/traces.txt'
02-16 13:01:31.183: INFO/dalvikvm(106): Wrote stack trace to '/data/anr/traces.txt'
答案 0 :(得分:1)
你应该给我们执行的代码,如果你只是调用一个方法,也给我们代码的代码。 Yous system.out将打印在logcat中,只需检查标记System
。
即使没有你的代码,我也可以开始一个有根据的猜测:你的按钮可能会触发一个长时间的操作并阻止UI线程,因为touchlistener在UI线程上运行。 您还应该考虑将其移动到AsyncTask中,该AsyncTask旨在用于互联网访问或计算等长期操作。您也可以从AsyncTask轻松更新UI。