# Set Up User Feedback

## Learn how to enable User Feedback in your Android app.

The User Feedback feature allows you to collect user feedback from anywhere inside your application at any time, without needing an error event to occur first.

If you're using a self-hosted Sentry instance, you'll need to be on version 24.4.2 or higher in order to use the full functionality of the User Feedback feature. Lower versions may have limited functionality. Ensure you are using the Android SDK version 8.14.0 or above of the SDK to access the latest features.

## [Widget](#widget)

The widget is a custom button that opens the feedback form. You can use it directly in your layout XML or instantiate it programmatically:

`myLayout.xml`

```xml
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
>

    <io.sentry.android.core.SentryUserFeedbackButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
  />
</LinearLayout>
```

## [User Feedback Form](#user-feedback-form)

The User Feedback form allows users to submit feedback from anywhere inside your application. For the configuration options, please refer to the [User Feedback Widget Configuration](/platforms/android/user-feedback/configuration/).

```java
import io.sentry.android.core.SentryUserFeedbackDialog;

// Just instantiate the dialog and show it whenever you want
new SentryUserFeedbackDialog.Builder(context).create().show();
```

### [Session Replay](#session-replay)

The User Feedback widget integrates seamlessly with Session Replay. When the widget is opened, the SDK buffers up to 30 seconds of the user's session. If feedback is submitted, this replay is sent along with the feedback, allowing you to view both the feedback and the user's actions leading up to the feedback submission.

## [User Feedback API](#user-feedback-api)

The User Feedback API allows you to collect user feedback while using your own UI components. You can submit feedback directly using the `Sentry.captureFeedback(Feedback)` method:

```java
import io.sentry.Sentry;
import io.sentry.protocol.Feedback;

Feedback feedback = new Feedback("I encountered a bug while using the app.");
feedback.setName("John Doe");
feedback.setContactEmail("john.doe@example.com");
// Optionally associate the feedback with an event
SentryId sentryId = Sentry.captureMessage("My message");
feedback.setAssociatedEventId(sentryId);
Sentry.captureFeedback(feedback);
```
