# BundleableByteArray

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/BundleableByteArray.java+class:androidx.media3.common.BundleableByteArray)

*** ** * ** ***

<br />

```
@UnstableApi
class BundleableByteArray
```

<br />

*** ** * ** ***

A wrapper for byte arrays that allows them to be transferred over `https://developer.android.com/reference/android/os/Bundle.html` instances using shared memory.

This class should be used for transferring byte arrays whose size is not trivially small, e.g. below 5000 bytes, to ensure it stays well below the binder transaction limits.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/BundleableByteArray#BundleableByteArray(byte[])(byteArray: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Creates the bundleable byte array. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/BundleableByteArray#fromBundle(android.os.Bundle)(bundle: https://developer.android.com/reference/android/os/Bundle.html!)` Reads a bundleable byte array from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/BundleableByteArray#toBundle()()` Writes a reference to the byte array to a `https://developer.android.com/reference/android/os/Bundle.html`. |

## Public constructors

### BundleableByteArray

```
BundleableByteArray(byteArray: ByteArray<Byte>!)
```

Creates the bundleable byte array.

| Parameters |
|---|---|
| `byteArray: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The byte array to wrap. This class assumes this array will not be modified after being passed to this constructor. |

## Public functions

### fromBundle

```
java-static fun fromBundle(bundle: Bundle!): Array<Byte>?
```

Reads a bundleable byte array from a `https://developer.android.com/reference/android/os/Bundle.html`.

| Parameters |
|---|---|
| `bundle: https://developer.android.com/reference/android/os/Bundle.html!` | The `https://developer.android.com/reference/android/os/Bundle.html` to read from. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | The bundleable byte array, or null if the key is not present or malformed. |

### toBundle

```
fun toBundle(): Bundle!
```

Writes a reference to the byte array to a `https://developer.android.com/reference/android/os/Bundle.html`.