Example usage for android.app ApplicationErrorReport TYPE_ANR

List of usage examples for android.app ApplicationErrorReport TYPE_ANR

Introduction

In this page you can find the example usage for android.app ApplicationErrorReport TYPE_ANR.

Prototype

int TYPE_ANR

To view the source code for android.app ApplicationErrorReport TYPE_ANR.

Click Source Link

Document

An error report about an application that's not responding.

Usage

From source file:net.frakbot.FWeather.util.FeedbackService.java

/**
 * Sends a feedback using the Android/Play Store built-in feedback mechanism.
 * Falls back on email if anything goes wrong (on our side)
 *///from  w ww.ja v a  2s.  c om
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void sendNativeFeedback() {
    Intent i = new Intent(Intent.ACTION_APP_ERROR);

    // Use the native ApplicationErrorReport
    ApplicationErrorReport report = new ApplicationErrorReport();
    report.processName = getApplication().getPackageName();
    report.packageName = report.processName;
    report.time = System.currentTimeMillis();
    report.type = ApplicationErrorReport.TYPE_ANR; // Fake ANR so that it shows up on the Play Store Dev Console
    report.systemApp = false;

    report.anrInfo = new ApplicationErrorReport.AnrInfo();
    report.anrInfo.activity = "none";
    report.anrInfo.cause = "USER FEEDBACK";
    report.anrInfo.info = "USER FEEDBACK";

    i.putExtra(Intent.EXTRA_BUG_REPORT, report);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    FLog.i(TAG, "Starting feedback intent");
    try {
        startActivity(i);
        stopForeground(true);
    } catch (Exception e) {
        FLog.w(this, "Unable to dispatch feedback Intent, falling back to email", e);
        sendFeedbackEmail();
    }
}