ANR和Android中的崩溃之间有什么区别? [英] What is the difference between ANR and crash in Android?

查看:394
本文介绍了ANR和Android中的崩溃之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上搜索了什么是ANR.我也研究了这些参考资料.但是我没有关于Android崩溃的详细信息.

I have searched on the internet regarding what an ANR is. And I studied those references as well. But I don't get details regarding a crash in Android.

有人可以告诉我ANR(Android无法响应)与Android崩溃之间的区别吗?

Can someone tell me the difference between ANR(Android not Responding) and a crash in Android?

推荐答案

ANR代表 A 复制 N ot R .

ANR stands for Application Not Responding.

如果您在UI线程上运行一个过程需要很长时间(通常约5秒钟),则会发生ANR.在此期间,GUI(图形用户界面)将被锁定,这将导致用户按下的任何操作均不起作用.大约5秒钟后,如果线程仍未恢复,则会显示ANR对话框,通知用户该应用程序没有响应,并为用户提供了选择等待的一种选择,希望该应用程序能够最终恢复,或强制关闭该应用程序.

An ANR will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned. After the 5 seconds approx has occurred, if the thread still hasn't recovered then an ANR dialogue box is shown informing the user that the application is not responding and will give the user the choice to either wait, in the hope that the app will eventually recover, or to force close the app.

崩溃是指在应用程序内引发了未处理的异常.例如,如果您尝试设置EditText组件的文本,但EditText为null,并且没有try catch语句来捕获应用程序将崩溃并被强制关闭的异常.用户将不会看到导致崩溃的原因,将向他们显示一个对话框,告诉您该应用已意外关闭,并将为他们提供发送错误报告的选项.在此示例中,如果您要查看错误报告,则会看到由java.lang.NullPointerException引起的错误.

A crash is when an exception within the app has been thrown which has not been handled. For example, if you try to set the text of an EditText component, but the EditText is null and there is no try catch statement to catch the exception that your app will crash and will be force closed. The user will not see what caused the crash, they will be shown a dialogue telling that the app has force closed unexpectedly and will give them the option to send a bug report. In this example if you were to look in the bug report you would see the error caused by java.lang.NullPointerException.

希望这会有所帮助.

这篇关于ANR和Android中的崩溃之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆