Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/hardware/HardwareBuffer#constants) \| [Inherited Constants](https://developer.android.com/reference/android/hardware/HardwareBuffer#inhconstants) \| [Fields](https://developer.android.com/reference/android/hardware/HardwareBuffer#lfields) \| [Methods](https://developer.android.com/reference/android/hardware/HardwareBuffer#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/hardware/HardwareBuffer#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/hardware/HardwareBuffer#inhmethods)

# HardwareBuffer

*** ** * ** ***


`
public

final

class
HardwareBuffer
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


implements

https://developer.android.com/reference/java/lang/AutoCloseable,

https://developer.android.com/reference/android/os/Parcelable


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.hardware.HardwareBuffer |

<br />

*** ** * ** ***

HardwareBuffer wraps a native `AHardwareBuffer` object, which is a low-level object
representing a memory buffer accessible by various hardware units. HardwareBuffer allows sharing
buffers across different application processes. In particular, HardwareBuffers may be mappable
to memory accessible to various hardware systems, such as the GPU, a sensor or context hub, or
other auxiliary processing units.

For more information, see the NDK documentation for `AHardwareBuffer`.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRA_1010102` 32-bit packed format that has 2-bit A, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRX_1010102` 32-bit packed format that has 2-bit unused, 10-bit R, G, and B components, in that order, from the most-significant bits to the least-significant bits. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#BLOB` Format: opaque format used for raw data transfer; must have a height of 1 |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_24UI8` Format: 24 bits depth, 8 bits stencil |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_FP32UI8` Format: 32 bits depth, 8 bits stencil |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_16` Format: 16 bits depth |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_24` Format: 24 bits depth |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_FP32` Format: 32 bits depth |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_10101010` Format: 10 bits each red, green, blue, alpha |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_1010102` Format: 10 bits each red, green, blue, 2 bits alpha |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_12121212` 64-bit format that has 12-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_14141414` 64-bit format that has 14-bit R, G, B, and A components, in that order, from the lowest memory address to the highest memory address. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_8888` Format: 8 bits each red, green, blue, alpha. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_FP16` Format: 16 bits each red, green, blue, alpha |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBX_8888` Format: 8 bits each red, green, blue, alpha, alpha is always 0xFF |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_565` Format: 5 bits each red and blue, 6 bits green, no alpha |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_888` Format: 8 bits each red, green, blue, no alpha |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1212` 32-bit format that has 12-bit R and G components, in that order, from the lowest memory address to the highest memory address. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1414` 32-bit format that has 14-bit R and G components, in that order, from the lowest memory address to the highest memory address. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1616` Format: 16 bits each red, green. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_12` 16 bit format with a single 12-bit component. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_14` 16 bit format with a single 14-bit component. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_16` Format: 16 bits red. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_8` Format: 8 bits red |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#S_UI8` Format: 8 bits stencil |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` The buffer will be used as a hardware composer overlay layer. |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_OFTEN` Usage: The buffer will often be read by the CPU |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_RARELY` Usage: The buffer will sometimes be read by the CPU. |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_OFTEN` Usage: The buffer will often be written to by the CPU |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_RARELY` Usage: The buffer will sometimes be written to by the CPU |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_FRONT_BUFFER` Usage: The buffer is used for front-buffer rendering. |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_COLOR_OUTPUT` Usage: The buffer will be written to by the GPU |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_CUBE_MAP` Usage: The buffer will be used as a cube map texture |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_DATA_BUFFER` Usage: The buffer will be used as a shader storage or uniform buffer object |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_MIPMAP_COMPLETE` Usage: The buffer contains a complete mipmap hierarchy |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` Usage: The buffer will be read from by the GPU |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_PROTECTED_CONTENT` Usage: The buffer must not be used outside of a protected hardware path |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_SENSOR_DIRECT_DATA` Usage: The buffer will be used for sensor direct data |
| `long` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_VIDEO_ENCODE` Usage: The buffer will be read by a hardware video encoder |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_420_888` Format: Planar YCbCr 420; must have an even width and height |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P010` <br /> Android YUV P010 format. |
| `int` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P210` <br /> Android YUV P210 format. |

| ### Inherited constants |
|---|
| From interface `https://developer.android.com/reference/android/os/Parcelable` |---|---| | `int` | `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor. | | `int` | `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE` Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". | |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/hardware/HardwareBuffer>` | `https://developer.android.com/reference/android/hardware/HardwareBuffer#CREATOR` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#close()() ` Destroys this buffer immediately. |
| ` static https://developer.android.com/reference/android/hardware/HardwareBuffer` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#create(int,%20int,%20int,%20int,%20long)(int width, int height, int format, int layers, long usage) ` Creates a new `HardwareBuffer` instance. |
| ` int` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| ` int` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getFormat()() ` Returns the @Format of this buffer. |
| ` int` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getHeight()() ` Returns the height of this buffer in pixels. |
| ` long` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getId()() ` Returns the system-wide unique id for this buffer This can be useful as a cache key for associating additional objects with a given HardwareBuffer, such as associating an imported EGLImage with the target HardwareBuffer when processing a stream of buffers from ImageReader. |
| ` int` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getLayers()() ` Returns the number of layers in this buffer. |
| ` long` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getUsage()() ` Returns the usage flags of the usage hints set on this buffer. |
| ` int` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#getWidth()() ` Returns the width of this buffer in pixels. |
| ` boolean` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#isClosed()() ` Indicates whether this buffer has been closed. |
| ` static boolean` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#isSupported(int,%20int,%20int,%20int,%20long)(int width, int height, int format, int layers, long usage) ` Queries whether the given buffer description is supported by the system. |
| ` void` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/hardware/HardwareBuffer#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||
| From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() ` Closes this resource, relinquishing any underlying resources. | ||
| From interface ` https://developer.android.com/reference/android/os/Parcelable ` |---|---| | ` abstract int` | ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() ` Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. | | ` abstract void` | ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) ` Flatten this object in to a Parcel. | ||

## Constants

### BGRA_1010102

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BGRA_1010102
```

32-bit packed format that has 2-bit A, 10-bit R, G, and B components,
in that order, from the most-significant bits to the least-significant
bits.

The component values are unsigned normalized to the range \[0, 1\], whose
interpretation is defined by the dataspace.

<br />

Constant Value:

67
(0x00000043)


### BGRX_1010102

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BGRX_1010102
```

32-bit packed format that has 2-bit unused, 10-bit R, G, and B components,
in that order, from the most-significant bits to the least-significant
bits.

The component values are unsigned normalized to the range \[0, 1\], whose
interpretation is defined by the dataspace.

<br />

Constant Value:

68
(0x00000044)


### BLOB

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BLOB
```

Format: opaque format used for raw data transfer; must have a height of 1

<br />

Constant Value:

33
(0x00000021)


### DS_24UI8

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DS_24UI8
```

Format: 24 bits depth, 8 bits stencil

<br />

Constant Value:

50
(0x00000032)


### DS_FP32UI8

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DS_FP32UI8
```

Format: 32 bits depth, 8 bits stencil

<br />

Constant Value:

52
(0x00000034)


### D_16

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int D_16
```

Format: 16 bits depth

<br />

Constant Value:

48
(0x00000030)


### D_24

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int D_24
```

Format: 24 bits depth

<br />

Constant Value:

49
(0x00000031)


### D_FP32

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int D_FP32
```

Format: 32 bits depth

<br />

Constant Value:

51
(0x00000033)


### RGBA_10101010

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_10101010
```

Format: 10 bits each red, green, blue, alpha

<br />

Constant Value:

59
(0x0000003b)


### RGBA_1010102

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_1010102
```

Format: 10 bits each red, green, blue, 2 bits alpha

<br />

Constant Value:

43
(0x0000002b)


### RGBA_12121212

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_12121212
```

64-bit format that has 12-bit R, G, B, and A components, in that order,
from the lowest memory address to the highest memory address. The
format is 64-bit unsigned integer that has a 12-bit R component in
the top 12 bits of the word in bytes 0..1, a 12-bit G component in
the top 12 bits of the word in bytes 2..3, a 12-bit B component in
the top 12 bits of the word in bytes 4..5, and a 12-bit A component
in the top 12 bits of the word in bytes 6..7, with the bottom 4 bits
of each word unused.

<br />

Constant Value:

65
(0x00000041)


### RGBA_14141414

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_14141414
```

64-bit format that has 14-bit R, G, B, and A components, in that order,
from the lowest memory address to the highest memory address. The
format is 64-bit unsigned integer that has a 14-bit R component in
the top 14 bits of the word in bytes 0..1, a 14-bit G component in
the top 14 bits of the word in bytes 2..3, a 14-bit B component in
the top 14 bits of the word in bytes 4..5, and a 14-bit A component
in the top 14 bits of the word in bytes 6..7, with the bottom 2 bits
of each word unused.

<br />

Constant Value:

66
(0x00000042)


### RGBA_8888

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_8888
```

Format: 8 bits each red, green, blue, alpha.


Value is one of the following:

- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_8888`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_FP16`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_1010102`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBX_8888`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_888`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_565`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#BLOB`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_420_888`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_16`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_24`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_24UI8`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_FP32`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_FP32UI8`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#S_UI8`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P010`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P210`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_8`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_16`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1616`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_10101010`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_12`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_14`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1212`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1414`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_12121212`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_14141414`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRA_1010102`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRX_1010102`
  - Constant Value: 1 (0x00000001)

### RGBA_FP16

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBA_FP16
```

Format: 16 bits each red, green, blue, alpha

<br />

Constant Value:

22
(0x00000016)


### RGBX_8888

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGBX_8888
```

Format: 8 bits each red, green, blue, alpha, alpha is always 0xFF

<br />

Constant Value:

2
(0x00000002)


### RGB_565

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGB_565
```

Format: 5 bits each red and blue, 6 bits green, no alpha

<br />

Constant Value:

4
(0x00000004)


### RGB_888

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RGB_888
```

Format: 8 bits each red, green, blue, no alpha

<br />

Constant Value:

3
(0x00000003)


### RG_1212

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RG_1212
```

32-bit format that has 12-bit R and G components, in that order,
from the lowest memory address to the highest memory address. The
format is 32-bit unsigned integer that has a 12-bit R component
in the top 12 bits of the word in bytes 0..1, and a 12-bit G
component in the top 12 bits of the word in bytes 2..3, with the
bottom 4 bits of each word unused.

<br />

Constant Value:

63
(0x0000003f)


### RG_1414

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RG_1414
```

32-bit format that has 14-bit R and G components, in that order,
from the lowest memory address to the highest memory address. The
format is 32-bit unsigned integer that has a 14-bit R component
in the top 14 bits of the word in bytes 0..1, and a 14-bit G
component in the top 14 bits of the word in bytes 2..3, with the
bottom 2 bits of each word unused.

<br />

Constant Value:

64
(0x00000040)


### RG_1616

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RG_1616
```

Format: 16 bits each red, green. When sampled on the GPU this is represented
as an unsigned integer instead of implicit unsigned normalize.
For more information see https://www.khronos.org/opengl/wiki/Normalized_Integer

<br />

Constant Value:

58
(0x0000003a)


### R_12

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int R_12
```

16 bit format with a single 12-bit component. The format is 16 bits
unsigned integer that has 12 bits of R component in the top 12 bits
of the 16-bit word with the bottom 4 bits unused.

<br />

Constant Value:

61
(0x0000003d)


### R_14

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int R_14
```

16 bit format with a single 14-bit component. The format is 16-bit
unsigned integer that has 14 bits of R component in the top 14 bits
of the 16-bit word with the bottom 2 bits unused.

<br />

Constant Value:

62
(0x0000003e)


### R_16

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int R_16
```

Format: 16 bits red. When sampled on the GPU this is represented as an
unsigned integer instead of implicit unsigned normalize.
For more information see https://www.khronos.org/opengl/wiki/Normalized_Integer

<br />

Constant Value:

57
(0x00000039)


### R_8

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int R_8
```

Format: 8 bits red

<br />

Constant Value:

56
(0x00000038)


### S_UI8

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int S_UI8
```

Format: 8 bits stencil

<br />

Constant Value:

53
(0x00000035)


### USAGE_COMPOSER_OVERLAY

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_COMPOSER_OVERLAY
```

The buffer will be used as a hardware composer overlay layer. That is, it will be displayed
using the system compositor via `https://developer.android.com/reference/android/view/SurfaceControl`

This flag is currently only needed when using
`https://developer.android.com/reference/android/view/SurfaceControl.Transaction#setBuffer(android.view.SurfaceControl,%20android.hardware.HardwareBuffer)`
to set a buffer. In all other cases, the framework adds this flag
internally to buffers that could be presented in a composer overlay.

<br />

Constant Value:

2048
(0x0000000000000800)


### USAGE_CPU_READ_OFTEN

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_CPU_READ_OFTEN
```

Usage: The buffer will often be read by the CPU

<br />

Constant Value:

3
(0x0000000000000003)


### USAGE_CPU_READ_RARELY

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_CPU_READ_RARELY
```

Usage: The buffer will sometimes be read by the CPU.


Value is either `0` or a combination of the following:

- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_RARELY`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_OFTEN`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_RARELY`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_OFTEN`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_COLOR_OUTPUT`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_PROTECTED_CONTENT`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_VIDEO_ENCODE`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_DATA_BUFFER`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_SENSOR_DIRECT_DATA`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_CUBE_MAP`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_MIPMAP_COMPLETE`
- `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_FRONT_BUFFER`
  - Constant Value: 2 (0x0000000000000002)

### USAGE_CPU_WRITE_OFTEN

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_CPU_WRITE_OFTEN
```

Usage: The buffer will often be written to by the CPU

<br />

Constant Value:

48
(0x0000000000000030)


### USAGE_CPU_WRITE_RARELY

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_CPU_WRITE_RARELY
```

Usage: The buffer will sometimes be written to by the CPU

<br />

Constant Value:

32
(0x0000000000000020)


### USAGE_FRONT_BUFFER

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_FRONT_BUFFER
```

Usage: The buffer is used for front-buffer rendering. When front-buffering rendering is
specified, different usages may adjust their behavior as a result. For example, when
used as USAGE_GPU_COLOR_OUTPUT the buffer will behave similar to a single-buffered window.
When used with USAGE_COMPOSER_OVERLAY, the system will try to prioritize the buffer
receiving an overlay plane \& avoid caching it in intermediate composition buffers.

<br />

Constant Value:

4294967296
(0x0000000100000000)


### USAGE_GPU_COLOR_OUTPUT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_GPU_COLOR_OUTPUT
```

Usage: The buffer will be written to by the GPU

<br />

Constant Value:

512
(0x0000000000000200)


### USAGE_GPU_CUBE_MAP

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_GPU_CUBE_MAP
```

Usage: The buffer will be used as a cube map texture

<br />

Constant Value:

33554432
(0x0000000002000000)


### USAGE_GPU_DATA_BUFFER

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_GPU_DATA_BUFFER
```

Usage: The buffer will be used as a shader storage or uniform buffer object

<br />

Constant Value:

16777216
(0x0000000001000000)


### USAGE_GPU_MIPMAP_COMPLETE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_GPU_MIPMAP_COMPLETE
```

Usage: The buffer contains a complete mipmap hierarchy

<br />

Constant Value:

67108864
(0x0000000004000000)


### USAGE_GPU_SAMPLED_IMAGE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_GPU_SAMPLED_IMAGE
```

Usage: The buffer will be read from by the GPU

<br />

Constant Value:

256
(0x0000000000000100)


### USAGE_PROTECTED_CONTENT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_PROTECTED_CONTENT
```

Usage: The buffer must not be used outside of a protected hardware path

<br />

Constant Value:

16384
(0x0000000000004000)


### USAGE_SENSOR_DIRECT_DATA

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_SENSOR_DIRECT_DATA
```

Usage: The buffer will be used for sensor direct data

<br />

Constant Value:

8388608
(0x0000000000800000)


### USAGE_VIDEO_ENCODE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final long USAGE_VIDEO_ENCODE
```

Usage: The buffer will be read by a hardware video encoder

<br />

Constant Value:

65536
(0x0000000000010000)


### YCBCR_420_888

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int YCBCR_420_888
```

Format: Planar YCbCr 420; must have an even width and height

<br />

Constant Value:

35
(0x00000023)


### YCBCR_P010

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int YCBCR_P010
```

<br />

Android YUV P010 format.
P010 is a 4:2:0 YCbCr semiplanar format comprised of a WxH Y plane followed by a Wx(H/2) CbCr plane. Each sample is represented by a 16-bit little-endian value, with the lower 6 bits set to zero.

<br />

<br />

Constant Value:

54
(0x00000036)


### YCBCR_P210

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int YCBCR_P210
```

<br />

Android YUV P210 format.
P210 is a 4:2:2 YCbCr semiplanar format comprised of a WxH Y plane followed by a WxH CbCr plane. Each sample is represented by a 16-bit little-endian value, with the lower 6 bits set to zero.

<br />

<br />

Constant Value:

60
(0x0000003c)


## Fields

### CREATOR

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<HardwareBuffer> CREATOR
```

<br />

<br />

## Public methods

### close

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Destroys this buffer immediately. Calling this method frees up any
underlying native resources. After calling this method, this buffer
must not be used in any way.

<br />

**See also:**

- `https://developer.android.com/reference/android/hardware/HardwareBuffer#isClosed()`

### create

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static HardwareBuffer create (int width, 
                int height, 
                int format, 
                int layers, 
                long usage)
```

Creates a new `HardwareBuffer` instance.

Calling this method will throw an `IllegalStateException` if
format is not a supported Format type.

<br />

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width in pixels of the buffer. Value is 1 or greater <br /> |
| `height` | `int`: The height in pixels of the buffer. Value is 1 or greater <br /> |
| `format` | `int`: The @Format of each pixel. Value is one of the following: - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_FP16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBX_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_565` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BLOB` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_420_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_24` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_24UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_FP32` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_FP32UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#S_UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P210` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1616` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_10101010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_12` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_14` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_12121212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_14141414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRX_1010102` |
| `layers` | `int`: The number of layers in the buffer. Value is 1 or greater <br /> |
| `usage` | `long`: The @Usage flags describing how the buffer will be used. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_RARELY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_OFTEN` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_RARELY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_OFTEN` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_COLOR_OUTPUT` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_PROTECTED_CONTENT` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_VIDEO_ENCODE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_DATA_BUFFER` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_SENSOR_DIRECT_DATA` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_CUBE_MAP` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_MIPMAP_COMPLETE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_FRONT_BUFFER` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/HardwareBuffer` | A `HardwareBuffer` instance if successful, or throws an IllegalArgumentException if the dimensions passed are invalid (either zero, negative, or too large to allocate), if the format is not supported, if the requested number of layers is less than one or not supported, or if the passed usage flags are not a supported set. This value cannot be `null`. <br /> |

### describeContents

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int describeContents ()
```

Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`,
the return value of this method must include the
`https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` bit.

<br />

| Returns ||
|---|---|
| `int` | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either `0` or - `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR` |

### getFormat

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getFormat ()
```

Returns the @Format of this buffer.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_FP16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBX_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_565` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BLOB` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_420_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_24` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_24UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_FP32` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_FP32UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#S_UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P210` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1616` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_10101010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_12` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_14` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_12121212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_14141414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRX_1010102` |

### getHeight

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getHeight ()
```

Returns the height of this buffer in pixels.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getId

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getId ()
```

Returns the system-wide unique id for this buffer

This can be useful as a cache key for associating additional objects with
a given HardwareBuffer, such as associating an imported EGLImage with
the target HardwareBuffer when processing a stream of buffers from
ImageReader.

This can also be useful for doing cross-process buffer caching. As sending
a HardwareBuffer over Binder is slower than sending a long, this can be
used as reliable cache key after an initial handshake that passes the
HardwareBuffers themselves to later be referred to using only the id.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getLayers

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getLayers ()
```

Returns the number of layers in this buffer.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getUsage

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getUsage ()
```

Returns the usage flags of the usage hints set on this buffer.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getWidth

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getWidth ()
```

Returns the width of this buffer in pixels.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### isClosed

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isClosed ()
```

Indicates whether this buffer has been closed. A closed buffer cannot
be used in any way: the buffer cannot be written to a parcel, etc.

<br />

| Returns ||
|---|---|
| `boolean` | True if this `HardwareBuffer` is in a closed state, false otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/hardware/HardwareBuffer#close()`

### isSupported

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isSupported (int width, 
                int height, 
                int format, 
                int layers, 
                long usage)
```

Queries whether the given buffer description is supported by the system. If this returns
true, then the allocation may succeed until resource exhaustion occurs. If this returns
false then this combination will never succeed.

<br />

| Parameters ||
|---|---|
| `width` | `int`: The width in pixels of the buffer. Value is 1 or greater <br /> |
| `height` | `int`: The height in pixels of the buffer. Value is 1 or greater <br /> |
| `format` | `int`: The @Format of each pixel. Value is one of the following: - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_FP16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBX_8888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGB_565` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BLOB` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_420_888` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_24` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_24UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#D_FP32` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#DS_FP32UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#S_UI8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#YCBCR_P210` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_8` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_16` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1616` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_10101010` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_12` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#R_14` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RG_1414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_12121212` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#RGBA_14141414` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRA_1010102` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#BGRX_1010102` |
| `layers` | `int`: The number of layers in the buffer. Value is 1 or greater <br /> |
| `usage` | `long`: The @Usage flags describing how the buffer will be used. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_RARELY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_READ_OFTEN` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_RARELY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_CPU_WRITE_OFTEN` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_SAMPLED_IMAGE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_COLOR_OUTPUT` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_COMPOSER_OVERLAY` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_PROTECTED_CONTENT` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_VIDEO_ENCODE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_DATA_BUFFER` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_SENSOR_DIRECT_DATA` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_CUBE_MAP` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_GPU_MIPMAP_COMPLETE` - `https://developer.android.com/reference/android/hardware/HardwareBuffer#USAGE_FRONT_BUFFER` |

| Returns ||
|---|---|
| `boolean` | True if the combination is supported, false otherwise. <br /> |

### writeToParcel

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void writeToParcel (Parcel dest, 
                int flags)
```

Flatten this object in to a Parcel.

Calling this method will throw an `IllegalStateException` if
`https://developer.android.com/reference/android/hardware/HardwareBuffer#close()` has been previously called.

<br />

<br />

| Parameters ||
|---|---|
| `dest` | `Parcel`: The Parcel in which the object should be written. <br /> |
| `flags` | `int`: Additional flags about how the object should be written. May be 0 or `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`. <br /> |

## Protected methods

### finalize

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void finalize ()
```

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the `finalize` method to dispose of
system resources or to perform other cleanup.


The general contract of `finalize` is that it is invoked
if and when the Java virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The `finalize` method may take any action, including
making this object available again to other threads; the usual purpose
of `finalize`, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.


The `finalize` method of class `Object` performs no
special action; it simply returns normally. Subclasses of
`Object` may override this definition.


The Java programming language does not guarantee which thread will
invoke the `finalize` method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.


After the `finalize` method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.


The `finalize` method is never invoked more than once by a Java
virtual machine for any given object.


Any exception thrown by the `finalize` method causes
the finalization of this object to be halted, but is otherwise
ignored.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/Throwable` |   |