Is “ANR” an exception or an error or what?

前端 未结 2 902
栀梦
栀梦 2020-12-17 08:43

Is the ANR an exception, an error or what? Can we actually catch it in a try{} catch(){} structure?

2条回答
  •  没有蜡笔的小新
    2020-12-17 09:22

    ANR (Application Not Responding) is not exactly an error. It is shown when your application is very sluggish and takes a lot of time to respond, thus making the user wait. The user won't appreciate if your application makes them wait for a long time. So, the Android framework gives the user an option of closing your application. http://developer.android.com/guide/practices/design/responsiveness.html

    This occurs when you are doing long running operations on the main thread. The system can't process user interactions during this period since the main thread is blocked. The solution is to do the heavy operations in a worker thread and keep the main thread free.

提交回复
热议问题