title: sending crash report via email using DefaultExceptionHandler
body: <h2>background</h2>
  
  <p>i'm trying to capture all crashes and allow the user to send my own customized error report via email.</p>
  
  <p>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.</p>
  
  <h2>how it works</h2>
  
  <p>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.</p>
  
  <p>the function stores some data on the external storage and immediately opens the email app (gmail) to send the crash report.</p>
  
  <h2>the problem</h2>
  
  <p>it works quite well, but for some reason, when i close the email app, the app itself is restarted.</p>
  
  <p>i've tried multiple combinations of :</p>
  
  <ul>
  <li>System.exit(0) </li>
  <li>android.os.Process.killProcess(android.os.Process.myPid());</li>
  <li>calling the default UncaughtExceptionHandler . </li>
  </ul>
  
  <p>none worked. it does close the app, but as soon as close the email app, the app restarts itself</p>
  
  <p>i also can't find out how to do things that work on the UI thread when capturing the crashes (such as toasts, dialogs,...) .</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>i've searched here (on SO) for a solution and found some posts, but none has worked for me.</p>
  
  <h2>the question</h2>
  
  <p>how can i avoid the app from being restarted when closing the email app?</p>