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?