Tuesday, September 15, 2009

Android: ANR

http://groups.google.com/group/android-platform/browse_thread/thread/84b200dda6300e39/021bf4d3de280321?lnk=gst&q=anr#021bf4d3de280321
http://developer.android.com/intl/zh-TW/guide/practices/design/responsiveness.html

Why:
  • No response to an input event (e.g. key press, screen touch) within 5 seconds
  • A BroadcastReceiver hasn't finished executing within 10 seconds


Solution:
  • any method that runs in the main thread should do as little work as possible
  • Activities should do as little as possible to set up in key life-cycle methods such as onCreate() and onResume()
  • Potentially long running operations should be done in a child thread, your main thread should provide a Handler for child threads to post back to upon completion
  • your application should start a Service if a potentially long running action needs to be taken in response to an Intent broadcast
  • avoid starting an Activity from an Intent Receiver

No comments:

Related Posts Plugin for WordPress, Blogger...