Alex Rivera | Logout

How to use Intent.ACTION_APP_ERROR as a means for a "feedback" framework in Android?

Asked 2012-05-11T22:10:52.097
16

I would like to reuse the Intent.ACTION_BUG_REPORT in my app, as a simple means of getting user feedback.

Google Maps uses it as their "Feedback" option. But I've not been successful in firing the event.

I'm using the following in a onOptionsItemSelected(MenuItem item):

    Intent intent = new Intent(Intent.ACTION_BUG_REPORT);
    startActivity(intent);

And in my AndroidManifest.xml I've declared the following under my Activity:

    <intent-filter>
       <action android:name="android.intent.action.BUG_REPORT" />
       <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

However, nothing seems to happen besides the screen "blink" when I select the option. The App or intent doesn't crash, it doesn't log anything. Tried it both in the Emulator and on an ICS 4.0.4 device.

I'm clealy missing something, but what?

Edit

Intent.ACTION_APP_ERROR (constant android.intent.action.BUG_REPORT) was added in API level 14, http://developer.android.com/reference/android/content/Intent.html#ACTION_APP_ERROR

Edit
Report

1 Answer

4

This was solved with the help from the link in @TomTasche comment above. Use built-in feedback mechanism on Android.

In my AndroidManifest.xml I added the following to the <Activity> where I want to call the Feedback agent from.

<intent-filter>
   <action android:name="android.intent.action.APP_ERROR" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

And I made a simple method called sendFeedback() (code from TomTasche blogpost)

@SuppressWarnings("unused")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void sendFeedback() {
    try {
        int i = 3 / 0;
    } catch (Exception e) {
    ApplicationErrorReport report = new ApplicationErrorReport();
    report.packageName = report.processName = getApplication().getPackageName();
    report.time = System.currentTimeMillis();
    report.type = ApplicationErrorReport.TYPE_CRASH;
    report.systemApp = false;

    ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
    crash.exceptionClassName = e.getClass().getSimpleName();
    crash.exceptionMessage = e.getMessage();

    StringWriter writer = new StringWriter();
    PrintWriter printer = new PrintWriter(writer);
    e.printStackTrace(printer);

    crash.stackTrace = writer.toString();

    StackTraceElement stack = e.getStackTrace()[0];
    crash.throwClassName = stack.getClassName();
    crash.throwFileName = stack.getFileName();
    crash.throwLineNumber = stack.getLineNumber();
    crash.throwMethodName = stack.getMethodName();

    report.crashInfo = crash;

    Intent intent = new Intent(Intent.ACTION_APP_ERROR);
    intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
    startActivity(intent);
    }
}

And from my SettingsActivit

answered 2013-04-26T08:55:53.143

Your Answer