sending crash report via email using DefaultExceptionHandler
Asked Answered
K

1

0

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 :

  • System.exit(0)
  • android.os.Process.killProcess(android.os.Process.myPid());
  • calling the default UncaughtExceptionHandler .

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?

Kief answered 7/7, 2013 at 12:56 Comment(0)
C
2

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.

Cornellcornelle answered 8/7, 2013 at 0:43 Comment(2)
it works very well. however, i still don't understand why i got into a loop that restarts the app each time i leave gmail. the example even has the ability to show a progressDialog without any problems. i now have no clue for why i had problems with my app. :(Kief
actually, i can see that the library has the same problem. it's just that it doesn't crash on the onCreate, but on the click of a button. they haven't fixed it, only avoided it. now the question is, how could this be. if i set the crash on the onCreate() method, i can see that the app will be restarted.Kief

© 2022 - 2024 — McMap. All rights reserved.