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

# Camera.PreviewCallback

*** ** * ** ***

` public static interface Camera.PreviewCallback `   
` `

|---|
| android.hardware.Camera.PreviewCallback |

<br />

*** ** * ** ***

<br />

**This interface was deprecated in API level 21.**   

We recommend using the new `https://developer.android.com/reference/android/hardware/camera2/package-summary` API for new applications.

Callback interface used to deliver copies of preview frames as they are displayed.
**See also:**

- `https://developer.android.com/reference/android/hardware/Camera#setPreviewCallback(android.hardware.Camera.PreviewCallback)`
- `https://developer.android.com/reference/android/hardware/Camera#setOneShotPreviewCallback(android.hardware.Camera.PreviewCallback)`
- `https://developer.android.com/reference/android/hardware/Camera#setPreviewCallbackWithBuffer(android.hardware.Camera.PreviewCallback)`
- `https://developer.android.com/reference/android/hardware/Camera#startPreview()`

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/hardware/Camera.PreviewCallback#onPreviewFrame(byte[],%20android.hardware.Camera)(byte[] data, https://developer.android.com/reference/android/hardware/Camera camera) ` Called as preview frames are displayed. |

## Public methods

### onPreviewFrame

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

```
public abstract void onPreviewFrame (byte[] data, 
                Camera camera)
```

Called as preview frames are displayed. This callback is invoked on the event thread `https://developer.android.com/reference/android/hardware/Camera#open(int)` was called from.

If using the `https://developer.android.com/reference/android/graphics/ImageFormat#YV12` format, refer to the equations in `https://developer.android.com/reference/android/hardware/Camera.Parameters#setPreviewFormat(int)` for the arrangement of the pixel data in the preview callback buffers.

<br />

| Parameters ||
|---|---|
| `data` | `byte`: the contents of the preview frame in the format defined by `https://developer.android.com/reference/android/graphics/ImageFormat`, which can be queried with `https://developer.android.com/reference/android/hardware/Camera.Parameters#getPreviewFormat()`. If `https://developer.android.com/reference/android/hardware/Camera.Parameters#setPreviewFormat(int)` is never called, the default will be the YCbCr_420_SP (NV21) format. <br /> |
| `camera` | `Camera`: the Camera service object. <br /> |