简体   繁体   English

通过ACRA报告我自己的例外情况

[英]Reporting my own exceptions through ACRA

Let's say I have something like this: 假设我有这样的事情:

int zero = 1;
if (zero!=0) {
    // have ACRA handle this as an error with stack trace and show the value
    // of zero, but silently, without the app crashing or bothering the user
}

How could I do this? 我该怎么办? I need it because I've exhausted most proper crashes, but my app still has errors that do not cause crashes and it would be nice to use the same error reporting system for those kind of errors as well. 我需要它是因为我已经用尽了大多数正常的崩溃,但是我的应用程序仍然存在不会导致崩溃的错误,对于这些类型的错误,也可以使用相同的错误报告系统。

I figured out how to send the app's Logcat output as part of the error report, but that seems too much, I only need a few values, maybe a single string. 我想出了如何将应用程序的Logcat输出发送为错误报告的一部分,但这似乎太多了,我只需要几个值,也许是一个字符串。

As explained in the ACRA advanced usage , you can use ErrorReporter.handleSilentException() to send any abnormal state to ACRA without notifying the user. ACRA高级用法中所述 ,您可以使用ErrorReporter.handleSilentException()将任何异常状态发送给ACRA,而无需通知用户。 If you don't have a 'real' Exception to pass in as the parameter, you can either create your own ( new RuntimeException("zero!=0") ) or pass in null to use the default new Exception("Report requested by developer") . 如果没有作为参数传递的“真实”异常,则可以创建自己的( new RuntimeException("zero!=0") )或传递null以使用默认的new Exception("Report requested by developer")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM