# RecompositionTracingReceiver

Artifact: [androidx.compose.runtime:runtime-tracing](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/tracing/RecompositionTracingReceiver.kt+class:androidx.compose.runtime.tracing.RecompositionTracingReceiver) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.13.0-rc01)


```
class RecompositionTracingReceiver : BroadcastReceiver
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) ||
|   | ↳ | [androidx.compose.runtime.tracing.RecompositionTracingReceiver](https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver) |

*** ** * ** ***

Receives broadcast intents to start and stop the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/RecompositionTracer`.

`https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/RecompositionTracer` is a higher overhead debugging tool that collects information about state reads and writes that affect composition into a Perfetto trace.

This receiver can be started at any point of time to start and stop the tracing. The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tooling/RecompositionTracer` will automatically find all existing compositions and start observations from there.

Supported actions:

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#ACTION_START()` - Starts recomposition tracing

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#ACTION_STOP()` - Stops recomposition tracing

Result codes:

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_SUCCESS()` - Successfully installed the tracer

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_ALREADY_IN_PROGRESS()` - Tracing is already in progress

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_FAILURE()` - Failed to install or stop the tracer

This receiver is generally not expected to be called directly by the user and should only be used by surrounding tooling (e.g. macrobenchmarks) to actually start and stop the tracing.

To start the receiver, use:

```kotlin
 adb shell am broadcast \
-a androidx.compose.tracing.action.START_RECOMPOSE_TRACING \
$package/androidx.compose.runtime.tracing.RecompositionTracingReceiver
```

To stop the receiver, use:

```kotlin
adb shell am broadcast \
-a androidx.compose.tracing.action.STOP_RECOMPOSE_TRACING \
$package/androidx.compose.runtime.tracing.RecompositionTracingReceiver
```

Where `$package` is your application's package name.

Note that enabled / disabled state for recomposition tracing is persisted until app reinstall.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#ACTION_START()` Start recomposition tracing. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#ACTION_STOP()` Stop recomposition tracing. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_ALREADY_IN_PROGRESS() = 2` Did not start recomposition tracing. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_FAILURE() = 3` Failed to start or stop recomposition tracing. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RESULT_CODE_SUCCESS() = 1` Successfully started or stopped recomposition tracing. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#RecompositionTracingReceiver()()` |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/tracing/RecompositionTracingReceiver#onReceive(android.content.Context,android.content.Intent)(context: https://developer.android.com/reference/android/content/Context.html?, intent: https://developer.android.com/reference/android/content/Intent.html?)` Handles broadcast intents for starting or stopping recomposition tracing. |

### Inherited functions

From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#clearAbortBroadcast()()` `https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#getResultExtras(boolean)(makeMap: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://developer.android.com/reference/android/content/BroadcastReceiver.PendingResult.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#goAsync()()` `https://developer.android.com/reference/android/os/IBinder.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#peekService(android.content.Context, android.content.Intent)(myContext: https://developer.android.com/reference/android/content/Context.html, service: https://developer.android.com/reference/android/content/Intent.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setOrderedHint(boolean)(isOrdered: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResult(int, java.lang.String, android.os.Bundle)(code: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, extras: https://developer.android.com/reference/android/os/Bundle.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#setResultExtras(android.os.Bundle)(extras: https://developer.android.com/reference/android/os/Bundle.html)`

### Inherited properties

From [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#abortBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#debugUnregister` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#isInitialStickyBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#isOrderedBroadcast` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#resultCode` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#resultData` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#sentFromPackage` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/android/content/BroadcastReceiver.html#sentFromUid`

## Constants

### ACTION_START

```
const val ACTION_START: String
```

Start recomposition tracing.

### ACTION_STOP

```
const val ACTION_STOP: String
```

Stop recomposition tracing.

### RESULT_CODE_ALREADY_IN_PROGRESS

```
const val RESULT_CODE_ALREADY_IN_PROGRESS = 2: Int
```

Did not start recomposition tracing. Tracing is already in progress.

### RESULT_CODE_FAILURE

```
const val RESULT_CODE_FAILURE = 3: Int
```

Failed to start or stop recomposition tracing.

### RESULT_CODE_SUCCESS

```
const val RESULT_CODE_SUCCESS = 1: Int
```

Successfully started or stopped recomposition tracing.

## Public constructors

### RecompositionTracingReceiver

Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.13.0-rc01)

```
RecompositionTracingReceiver()
```

## Public functions

### onReceive

Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.13.0-rc01)

```
open fun onReceive(context: Context?, intent: Intent?): Unit
```

Handles broadcast intents for starting or stopping recomposition tracing.