本文介绍了是“ANR”一个例外或错误还是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ANR是一个例外,一个错误还是什么?我们可以在 try {} catch(){} 结构中抓住它

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

推荐答案

ANR (应用程序不响应)并不完全是错误。当您的应用程序非常缓慢并需要大量时间进行响应时显示,从而使用户等待。如果您的应用程序使它们等待很长时间,用户将不会欣赏。因此,Android框架为用户提供关闭应用程序的选项。

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.

这篇关于是“ANR”一个例外或错误还是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 17:12
查看更多