How to catch application crash report

I am developing an Android application. I want to send an email to myself whenever the application crashes to the device, so I can find the application crash report via email. How can I implement this concept in my application? Is there an exception handler for this?

+4
source share
3 answers

I catch exceptions without handling, using this in my onCreate() activity:

 mUEHandler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { try { PrintWriter pw = new PrintWriter(new OutputStreamWriter( openFileOutput(DMP_FILENAME, 0))); e.printStackTrace(pw); pw.flush(); pw.close(); } catch (FileNotFoundException e1) { // do nothing } BaseActivity.this.finish(); } }; Thread.setDefaultUncaughtExceptionHandler(mUEHandler); 

This writes every unhandled exception from your application that occurred in your activity to a text file. Then you can analyze it.

+18
source

I use ACRA http://code.google.com/p/acra/ to collect crash reports. Since they are compiled into a spreadsheet based on Google documents, you can set up a notification when this document is updated.

+2
source

If you add your application to the Android Market, Google will send crash reports to your email address. In fact, Google sends unhandled exceptions that occur in the application, which leads to a crash (forced close). No special code is needed for this.

0
source

All Articles