Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fproduct-features%2Fsession-replay%2Fandroid.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fproduct-features%2Fsession-replay%2Fandroid.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# Enable session replay on Android

Follow this guide to enable Session Replay for [Real User Monitoring (RUM)](https://coralogix.com/docs/user-guides/rum/getting-started/real-user-monitoring.md) in your Android app.

[Session Replay](https://coralogix.com/docs/user-guides/rum/product-features/session-replay.md) captures a visual sequence of user interactions in your app by recording periodic screenshots. This allows you to analyze what the user saw before, during, and after an issue, helping you quickly pinpoint the source of errors, performance slowdowns, or unexpected behavior. Use Session Replay to recreate the user experience and better understand the context behind each session.

## What you need[​](#what-you-need "Direct link to What you need")

Install and initialize the [Coralogix Android RUM SDK](https://coralogix.com/docs/user-guides/rum/sdk-installation/android.md) in your app before enabling Session Replay.

Note

Session Replay extends the Android RUM SDK and must be initialized **after** the base SDK. Attempting to initialize Session Replay without the base SDK results in an initialization error.

## Session Replay by default[​](#session-replay-by-default "Direct link to Session Replay by default")

Session Replay on Android:

* Evaluates UI one frame per second (FPS) and captures only if the layout changed since the previous screenshot.
* Masks all text inputs by default (`maskAllTexts = true`).
* Optionally masks only specific text values or regex patterns via `textsToMask` (when `maskAllTexts` is `false`).
* Redacts sensitive input field types (passwords, emails, numbers, etc.) when configured with `maskInputFieldsOfTypes`.
* Optionally masks all image views when `maskAllImages` is enabled.
* Samples 100% of sessions by default.

You can customize these defaults using the configuration options below.

## Configure and initialize[​](#configure-and-initialize "Direct link to Configure and initialize")

Use the `SessionReplayOptions` class to configure capture behavior, privacy masking, and sampling.

```
import android.app.Application

import com.coralogix.android.sdk.session_replay.SessionReplay

import com.coralogix.android.sdk.session_replay.model.SessionReplayOptions

import com.coralogix.android.sdk.internal.infrastructure.display.enums.EditTextType



class MyApp : Application() {

    override fun onCreate() {

        super.onCreate()



        // Step 1: initialize the Android RUM SDK.

        CoralogixRum.initialize(this, sdkOptions)



        // Step 2: initialize Session Replay.

        val sessionReplayOptions = SessionReplayOptions(

            captureScale = 0.5f,

            captureCompressQuality = 0.8f,

            sessionRecordingSampleRate = 80,

            autoStartSessionRecording = true,

            maskAllTexts = false,

            textsToMask = listOf("password", "secret.*"),

            maskInputFieldsOfTypes = listOf(

                EditTextType.PASSWORD,

                EditTextType.EMAIL

            ),

            maskAllImages = true

        )

        SessionReplay.initialize(this, sessionReplayOptions)

    }

}
```

## Options reference[​](#options-reference "Direct link to Options reference")

| Option                       | Type                 | Description                                                                                                                      | Default       |
| ---------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `autoStartSessionRecording`  | `Boolean`            | Start recording automatically.                                                                                                   | `true`        |
| `captureScale`               | `Float`              | Screenshot resolution scale factor (0–1). Lower values reduce size and memory usage.                                             | `0.5f`        |
| `captureCompressQuality`     | `Float`              | Image compression (0–1). Lower values reduce fidelity and file size.                                                             | `1.0f`        |
| `sessionRecordingSampleRate` | `Int` (0–100)        | Percentage of sessions to capture.                                                                                               | `100`         |
| `maskAllTexts`               | `Boolean`            | Redact all on-screen text.                                                                                                       | `true`        |
| `textsToMask`                | `List<String>`       | Redact only specific text values or regex patterns (used when `maskAllTexts` is `false`). Patterns use Kotlin/Java regex syntax. | `emptyList()` |
| `maskInputFieldsOfTypes`     | `List<EditTextType>` | Redact specific input field types (for example, password, email, phone).                                                         | `emptyList()` |
| `maskAllImages`              | `Boolean`            | Mask all `ImageView` instances on screen.                                                                                        | `false`       |
| `sampleFrameRatePerSecond`   | `Int` *(deprecated)* | **Deprecated. Do not change.** 1 fps is the only supported capture rate. This field will be removed in a future release.         | `1`           |

## Image capture triggers[​](#image-capture-triggers "Direct link to Image capture triggers")

Screenshots are captured during session replay in the following cases:

* User taps, scrolls, or swipes on the screen.
* User navigates between activities or fragments.
* A periodic capture triggers at 1 fps (layout change evaluation).
* An error or crash occurs.
* A manual capture is triggered via [`SessionReplay.captureScreenshot()`](#manually-capture-screen).

Android Session Replay combines periodic sampling with event-based captures (tap, error) so you still see key moments even if they occur between sampling intervals.

Note

Periodic sampling triggers a capture but only processes the frame if a meaningful layout change has taken place, to avoid noise and improve performance.

## Start and stop recording[​](#start-and-stop-recording "Direct link to Start and stop recording")

If `autoStartSessionRecording` is `false`, control recording manually:

```
SessionReplay.startSessionRecording()

SessionReplay.stopSessionRecording()
```

## Manually capture screen[​](#manually-capture-screen "Direct link to Manually capture screen")

Use `captureScreenshot` to capture a specific moment in the session:

```
SessionReplay.captureScreenshot()
```

## Shut down Session Replay[​](#shut-down-session-replay "Direct link to Shut down Session Replay")

Stop the recorder and release its resources. After shutdown, calling `startSessionRecording()` again has no effect until you re-initialize.

```
SessionReplay.shutdown()
```

## Privacy and masking[​](#privacy-and-masking "Direct link to Privacy and masking")

Coralogix provides flexible masking options to help you meet privacy requirements.

* **Text masking:** Use `maskAllTexts = true` to redact all on-screen text, or use `textsToMask` to selectively mask specific text values or regex patterns when `maskAllTexts` is `false`. Patterns use Kotlin/Java regex syntax (for example, `(?i)password` for case-insensitive matching).
* **Input field masking:** Protect sensitive data such as passwords, emails, and phone numbers by specifying their `EditTextType` in `maskInputFieldsOfTypes`.
* **Image masking:** Use `maskAllImages = true` to redact all `ImageView` instances on screen.
* **View masking:** Programmatically mark a specific view as sensitive:

```
mySensitiveView.maskView()
```

### What masking covers[​](#what-masking-covers "Direct link to What masking covers")

Masking applies to the whole subtree. Every child view is masked too, and a child cannot be opted back out. Masking a container is enough to cover everything inside it.

A masked view, and anything inside it:

* Is covered by a black overlay in session replays.
* Absorbs tap markers, a tap landing anywhere inside it draws no marker in the recording, so the replay does not reveal which part of the masked area was touched.
* Reports its inner text as `***` in user interaction events.

Everything else on the interaction event is reported as-is (the element’s ID, class, resolved element name, and touch coordinates) and the event is still emitted. The event carries `interaction_context.is_masked_element` (`true`/`false`) so you can enforce a stricter policy in `beforeSend`.

### Enforcing a stricter policy with `is_masked_element`[​](#enforcing-a-stricter-policy-with-is_masked_element "Direct link to enforcing-a-stricter-policy-with-is_masked_element")

Use the `beforeSend` callback to drop or redact masked interactions before they leave the device.

Drop every masked interaction:

```
beforeSend = { event ->

    if (event.interactionContext?.isMaskedElement == true) null else event

}
```

Keep the event but blank the coordinates:

```
beforeSend = { event ->

    if (event.interactionContext?.isMaskedElement == true) {

        event.copy(

            interactionContext = event.interactionContext?.copy(attributes = buildJsonObject {})

        )

    } else {

        event

    }

}
```

Tip

Always verify your masking rules in staging before going live, especially for sensitive inputs like login screens and payment forms.
