HomeDocumentationAPI Reference
Getting StartedAPI ReferenceBug ReportingCrash ReportingAPMHelp Center
Documentation

Crash Reporting Callbacks for Android

Covered here is how to set up the callbacks that fire before every crash report is sent so that a specific block of code is executed in your Android app.

🚧

Avoiding Memory Leaks

These APIs hold the callbacks in a strong reference, so we strongly suggest to avoid registering callbacks without unregistering them when needed, as it may cause a memory leak.

Before Sending a Report

This block is executed in the background before sending each report. You can use it to attach logs and extra data to reports.

Instabug.onReportSubmitHandler{report -> }
Instabug.onReportSubmitHandler(new Report.OnReportCreatedListener() {
            @Override
            public void onReportCreated(Report report) {
                
            }
        };

Exporting Crash Metadata

You can use the below API to capture metadata about the crash including:

  • Error Type: The error type including ANR (Foreground ANR), BG_ANR (Background ANR), Non-fatal errors and NDK crashes.
  • Error Code: The specific error code associated with the crash.
  • User Attributes: User attributes associated with the session.
  • Error Description: The error message associated with the crash
CrashReporting.setOnCrashSentCallback
CrashReporting.setOnCrashSentCallback

What’s Next

You can set custom data, such as a user attribute, at any time, including inside callbacks. Logging user events in callbacks is possible as well.