IS" ANR"异常或错误还是什么?异常、错误、IS、QUOT

2023-09-07 03:14:16 作者:永不停息

时的ANR例外,错误还是什么?我们实际上可以赶上它在一个尝试{}赶上(){} 结构?

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

推荐答案

ANR (应用程序无响应)不完全是一个error.It显示,当你的应用程序非常缓慢,需要大量的来不及反应使用户wait.The用户如果您的应用程序让他等待了很长的时间,以便在Android框架为用户提供了关闭您的应用程序了一个选项不是AP preciate。 http://developer.android.com/guide/practices/design/responsiveness.html

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 making the user wait.The user won't appreciate if your application makes him wait for a long time so the android framework gives the user an option of closing your applicaiton. http://developer.android.com/guide/practices/design/responsiveness.html

这会发生,当你正在做的主线程上长时间运行的业务和系统无法在此期间,因为主线程处理用户的交互是blocked.The解决办法是做繁重的业务工作线程,并保持主线程自由。

This occurs when you are doing long running operations on the main thread and 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.