android developer
android developer

Reputation: 116322

sending crash report via email using DefaultExceptionHandler

background

i'm trying to capture all crashes and allow the user to send my own customized error report via email.

it's a very temporary solution since i need to send the logs of the app and other information . it is not intended to be sent to end users . only a very tiny group of testers.

how it works

anyway, i've created a class that extends from java.lang.Thread.UncaughtExceptionHandler , and that has a function uncaughtException() . i register to it using Thread.setDefaultUncaughtExceptionHandler() and it really catches crashes.

the function stores some data on the external storage and immediately opens the email app (gmail) to send the crash report.

the problem

it works quite well, but for some reason, when i close the email app, the app itself is restarted.

i've tried multiple combinations of :

none worked. it does close the app, but as soon as close the email app, the app restarts itself

i also can't find out how to do things that work on the UI thread when capturing the crashes (such as toasts, dialogs,...) .

another solution that i've tried is opening a new activity that will send the crash report. sadly the app didn't even start the activity.

another thing i've tried is to read from the ACRA library, trying to figure out how they have handled crashes. sadly, i didn't understand what is going on there, even from a high level.

i've searched here (on SO) for a solution and found some posts, but none has worked for me.

the question

how can i avoid the app from being restarted when closing the email app?

Upvotes: 0

Views: 5990

Answers (1)

Simon
Simon

Reputation: 11190

After reading your question I thought I'd give crash reporting a go.

Here is my result: https://github.com/slightfoot/android-crash-reporting

It has all that you wanted and probably more.

Upvotes: 2

Related Questions