Sunday, October 21, 2012

Use built-in feedback mechanism on Android

Photo taken from:
I'm surprised that nobody wrote about this before - even StackOverflow has only a few questions concerning this topic - so I thought I'd share this with you.

Instead of a custom library like ACRA I wanted to use the built-in crash report / feedback mechanism on Android (the one you'd usually see after an app force closed). Other Google apps like Google+ and Maps use this mechanism too, although they're using it in a way a usual app can't seem to reproduce (they're sending a "Bug Report", I were only able to send a "Crash").

Anyway, I managed to send a crash report (including stacktrace, comment, etc) to the Android Developer Console, like we're used to from force closes and ANRs. Basically, all you have to do is send an intent (Intent.ACTION_APP_ERROR) with appropriate extras. You can find the code over at GitHub:

Unfortunately, this doesn't work out-of-the-box for versions older than Android 14. I figure it could work if you copy the ApplicationErrorReport class into your app though.