BundleableByteArray


@UnstableApi
public final class BundleableByteArray


A wrapper for byte arrays that allows them to be transferred over Bundle 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

BundleableByteArray(byte[] byteArray)

Creates the bundleable byte array.

Public methods

static @Nullable byte[]

Reads a bundleable byte array from a Bundle.

Bundle

Writes a reference to the byte array to a Bundle.

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 Bundle.

Parameters
Bundle bundle

The Bundle to read from.

Returns
@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 Bundle.