简体   繁体   中英

ACRA make it boring if there are many exceptions thrown

I use ACRA in my android application. It's very useful but sometimes boring.

Sometimes, there are several asynchronous tasks running in the background. And for season, all of them failed(eg can't connect to internet). ACRA will show the toast message again and again, and refused to exit.

Is it able to let ACRA just catch the first exception? Or just show the toast message once?


Update

add a demo: https://github.com/freewind/android-acra-multi-reports

There are 4 activities in this project. The last one will throw exception and each previous activity will throw exception in onActivityResult . You can see ACRA will report many times before exiting.

That sounds to me like you should actually catch some exceptions and don't let all of them bubble up.

ACRA registers a Thread.UncaughtExceptionHandler on the main thread. Here all uncaught exceptions (as the handler's name suggests) get processed. Usually that means that the application is about to crash and ACRA will do its reporting magic. ACRA uses several Threads itself to do its work and will wait until everything is finished before it actually kills the application's process. So I'd guess that if there are coming a lot of exceptions, ACRA is just so busy to process them that it won't come to the point were it would kill the process.

You could register your own implementation of UncaughtExceptionHandler to catch exceptions and decide when to hand them through to ACRA and when to do something else. If I'm not mistaken, ACRA will call through to the UncaughtExceptionHandler that has been registered before the ACRA init. So you could also try to chain those handlers.

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