简体   繁体   中英

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.

As explained in the ACRA advanced usage , you can use ErrorReporter.handleSilentException() to send any abnormal state to ACRA without notifying the user. 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") .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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