sending crash report via email using DefaultExceptionHandler

一世执手 提交于 2019-12-25 07:33:53

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17512340/sending-crash-report-via-email-using-defaultexceptionhandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!