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

*** ** * ** ***


```
@UnstableApi
public final 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/androidx/media3/common/BundleableByteArray#BundleableByteArray(byte[])(byte[] byteArray)` Creates the bundleable byte array. |

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/common/BundleableByteArray#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` 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/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

```
public BundleableByteArray(byte[] byteArray)
```

Creates the bundleable byte array.

| Parameters |
|---|---|
| `byte[] byteArray` | The byte array to wrap. This class assumes this array will not be modified after being passed to this constructor. |

## Public methods

### fromBundle

```
public static @Nullable byte[] fromBundle(Bundle bundle)
```

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

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | The bundleable byte array, or null if the key is not present or malformed. |

### toBundle

```
public Bundle toBundle()
```

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