How to add a Send feedback option on an app crashing?

4.1k Views Asked by At

How can I add a Send feedback option on an Android app crashing? This option is seen in Google's own apps and here is an example from Starbucks.

App has stopped dialog with Send Feedback

There are a number of very old answers to this question that involve programmatically creating something like this. They seem overly involved to make this show.

I'm surprised there isn't a simple way to implement this without putting a try catch around the entire app. Can this be enabled simply e.g. by enabling an option on the Google Play store console or by by adding something to the manifest?

I have not been able to find data on how to do this in the Android or Play Store documentation.

Update: We are using Crashlytics/Fabric as our crash reporting library

This image shows the default behaviour on Android 6.0.

enter image description here

And 8.0:

enter image description here

4

There are 4 best solutions below

7
On

I'm surprised there isn't a simple way to implement this without putting a try catch around the entire app

There is no means to put "a try catch around the entire app".

There are a wide range of crash reporting libraries for Android, some of which (e.g., ACRA) will support your sort of feedback option. Implementing a crash reporter is somewhat tricky, given that your app's process is in an unstable state when you crash, which is why we have tested and debugged libraries for this purpose.

Can this be enabled simply e.g. by enabling an option on the Google Play store console or by by adding something to the manifest?

The libraries will add something to the manifest as part of adding them to your app.

4
On

The Android platform will just do this for you. You don't need to add any additional code. Try throwing an exception from your app. You should see this.

See https://android-developers.googleblog.com/2010/05/google-feedback-for-android.html

Once you publish the app to playstore, the option to "Send feedback" will be visible. I think you are not able to see it because the app which you are testing is a version of the app not directly downloaded from playstore, e.g: one signed with debug keystore.

2
On

There are a bunch of libraries for doing this, but if you're like me and don't like the overhead of generic libraries for such a simple task, it's pretty easy to do yourself.

Here are a few steps to get you going:

1) Add a class that extends Application (if you don't have one already).

2) In it's onCreate use Thread.setDefaultUncaughtExceptionHandler to set a custom UncoughtExceptionHandler.

3) In the custom handler, start an activity using an intent with the Intent.FLAG_ACTIVITY_NEW_TASK flag. For this activity add the android:process=":crash" attribute in the manifest (crash can be whatever you want). This step will make sure the new activity will start on a different process (This is important because the old one has crashed and now in a stack rollback process beacuse of the exception).

4) In this activity, do whatever you need. (present the UI you wanted for the crash report, and/or send an e-mail to yourself). JavaMail is good for the silent E-mailing.

Note: In the UncaughtExceptionHandler, you get the Thread and the Exception of the crash. You can easily extract the stack trace by using:
final StringWriter stackTrace = new StringWriter(); exception.printStackTrace(new PrintWriter(stackTrace)); and/or extract the Thread name if you need those, and send them to the activity using the intent's bundle.

Hope This Helps

0
On

Just use Fabric and their Crashlytics platform - this will flag any crashes detected without involving user input. It will automatically notify you when any crashes are detected and will identify specific issues, including a stacktrace and versioning. This is in addition to their many other useful features tied into their platform - they've also now joined the Firebase team so more to follow over the coming weeks/months. I've been using the platform over the past few months to analyse 25 of my applications and found it highly effective to identify and fix any issues that have arisen.