Reputation: 217
I am developing android application. I want to send an email to myself whenever my app crashes on a device, so that I can find my application's crash report through email. How can I implement this concept in my app? Have any exception handler for it?
Upvotes: 5
Views: 6654
Reputation: 37126
I use ACRA http://code.google.com/p/acra/ to collect crash reports. Since these are collected into Google docs-based spreadsheet you can configure to be notified when that doc is updated
Upvotes: 2
Reputation: 2485
I am catching un-handled exceptions by using this in my activity's onCreate()
:
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 in your app that happened on your activity to text file. Then you can analyze it.
Upvotes: 18
Reputation: 22740
If you add your application to the Android Market, then Google sends crash reports to your e-mail too. Actually Google sends unhandled exceptions that occur in application that leads to crash (force close). No special code is needed for that.
Upvotes: 0