Skip to content

Instantly share code, notes, and snippets.

@jayeshcp
Last active December 21, 2015 14:28
Show Gist options
  • Save jayeshcp/6319423 to your computer and use it in GitHub Desktop.
Save jayeshcp/6319423 to your computer and use it in GitHub Desktop.
Android: Sending App Feedback from within App itself
/**
* Open Android's standard Feedback screen for users to send app feedback
* Create options menu, and on its click event call following method.
* Show this menu item, only if Build version is greater than or equal
* to ICE_CREAM_SANDWICH (4.0)
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void OpenFeedbackForm() {
// Check if Build is higher than or equal to Ice Cream Sandwich (4.0)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
try {
ApplicationErrorReport report = new ApplicationErrorReport();
report.packageName = report.processName = getApplication().getPackageName();
report.time = System.currentTimeMillis();
report.type = ApplicationErrorReport.TYPE_NONE; // TYPE_NONE to be used for general reporting.
// This can be changed to TYPE_CRASH to send crash report.
// However above change requires this code to be placed in
// Exception catch block !
report.systemApp = false;
// This ensures Android opens selection box for
// sending bug report (which is intended functionality)
Intent intent = new Intent(Intent.ACTION_APP_ERROR);
intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
startActivity(intent);
} catch (Exception e) {
//Log.e(TAG, e.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment