Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch all Force Closes and log with Google Analytics

Is there a way to intercept a FC before it exits my app so I can log it with Google Analytics? I understand that Force Closes come from uncaught exceptions but I don't want to surround every method with a Try/Catch.

I know the real answer is to write more defensive code but I thought that my code was already quite solid. I was surprised to find a few new errors logged by users with things like OutOfMemoryExceptions and Admob blowing up. I'd rather not have to rely on the kindness of users to send me errors.

like image 284
Haphazard Avatar asked Dec 01 '25 03:12

Haphazard


1 Answers

Thread.setUncaughtExceptionHandler().

That said, I'm not a fan of this, I'd rather have an app crash so users have the option to send a crash report. Sure, sucks short-term, but in the end, you'll get more detailed crash reports.

like image 145
EboMike Avatar answered Dec 05 '25 10:12

EboMike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!