> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/android/set-up-luciq-for-android/set-up-crash-reporting/crash-reporting-callbacks.md).

# Crash Reporting Callbacks

{% hint style="warning" %}

#### 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.
{% endhint %}

### 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.

{% tabs %}
{% tab title="Kotlin" %}
{% code overflow="wrap" %}

```kotlin
Luciq.onReportSubmitHandler{report -> }
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
Luciq.onReportSubmitHandler(new Report.OnReportCreatedListener() {
            @Override
            public void onReportCreated(Report report) {
                
            }
        });
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 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

{% tabs %}
{% tab title="Kotlin" %}
{% code overflow="wrap" %}

```kotlin
CrashReporting.setOnCrashSentCallback { metadata ->
    Log.d("Luciq", "Crash sent error=${metadata.errorType} attrs=${metadata.userAttributes}")
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
CrashReporting.setOnCrashSentCallback(new OnCrashSentCallback() {
            @Override
            public void onCrashSent(@NotNull CrashMetadata crashMetaData) {
                
            }
        });
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.luciq.ai/android/set-up-luciq-for-android/set-up-crash-reporting/crash-reporting-callbacks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
