Launch FeedbackActivity in my application like in Android Hangouts

后端 未结 3 1440
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 00:19

I would like to launch com.google.android.feedback.FeedbackActivity for my application. Like it happens in Hangouts application.

Does anyone knows which ex

3条回答
  •  无人及你
    2021-02-15 01:11

    Although it's not exactly the same, you can programmatically invoke a crash-report-dialog:

    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);
    

    More information here: http://blog.tomtasche.at/2012/10/use-built-in-feedback-mechanism-on.html

提交回复
热议问题