7

I would like the users of my android app to have the option to email me the stacktrace of any uncaught exception that crashes my app. Originally I thought I would just wrap every entry point to my app in a try/catch block, but there are far too many of these even in my tiny app for this to be reasonable.

So what I am really looking for is a way to specify some method to be the default handler for any uncaught exceptions. Any suggestions?

Segfault
  • 8,036
  • 3
  • 35
  • 54
  • I don’t understand, isn’t it a standard behaviour of Android. On my phone when an app crash, I can click a button which will send a report containing the stacktrace and other informations. – Guillaume Brunerie Jul 13 '11 at 10:38
  • Yes, Guillaume, but this question is a year and a half old and that feature was not yet in android. – Segfault Jul 25 '11 at 13:57

2 Answers2

11

You cannot do what the subject line states from an SDK application.

However:

So what I am really looking for is a way to specify some method to be the default handler for any uncaught exceptions. Any suggestions?

Use Thread.setDefaultUncaughtExceptionHandler().

Also, consider using Flurry or DroidDrop or something for the actual delivery of your exception data.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
6

You could also use Bugsense.com to get your exception data (it's free).

PS: I am the founder :)

Jon Romero
  • 4,062
  • 6
  • 36
  • 34