Your activity took to long to say to the Android OS 'hey i'm still alive'! (This is what the UI thread does).http://developer.android.com/guide/practices/design/responsiveness.htmlBasically if you make the UI thread do some complex task it's too busy doing your task to tell the OS that it is still 'alive'.http://developer.android.com/resources/articles/painless-threading.htmlYou should move your XML Parsing code to another thread, then use a callback to tell the UI thread you have finished and to do something with the result.http://developer.android.com/resources/articles/timed-ui-updates.html
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.public void onCreate() { StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectAll() .penaltyLog() .penaltyDeath() .build()); super.onCreate(); } using penaltyLog() you can watch the output of adb logcat while you use your application to see the violations as they happen.
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
super.onCreate();
} using penaltyLog() you can watch the output of adb logcat while you use your application to see the violations as they happen.
就像文章中所总结的,ANR的分类:
1.应用程序错误
2.Java application Hang
3.Dalvik/ Core Libraries的错误
4.kernel错误
5.Modem的问题各种ANR还需要具体情况具体分析,并没有一种通用的方法可以快速定位,唯一通用的办法就是logcat和dmesg了,这也是解决bug过程中必需的……希望有更多人参与讨论,针对不同模块,分享经验。
没什么啊 分享经验 共同进步 DDMS连上查看死在哪里 的确是基本思路呀
飘啊飘
今天一直忙,没来得及上来看。
多谢各位捧场,还被推荐,凡是回复的通通有分
方法大致是这样,但是本人很菜,还没有什么具体的经验~
mkdir /data/anr
kill -3 youapp_pidsee /data/anr/traces.txt
or kill -3 -zygote_pid
you'll get some more