# CaptureFailure

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#constants)\|[Methods](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#inhmethods)  

# CaptureFailure

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/hardware/camera2/CaptureFailure "View this page in Kotlin")\|Java

`
public


class
CaptureFailure
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

A report of failed capture for a single image capture from the image sensor.

CaptureFailures are produced by a[CameraDevice](https://developer.android.com/reference/android/hardware/camera2/CameraDevice)if processing a[CaptureRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest)fails, either partially or fully. Use[getReason()](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getReason())to determine the specific nature of the failed capture.

Receiving a CaptureFailure means that the metadata associated with that frame number has been dropped -- no[CaptureResult](https://developer.android.com/reference/android/hardware/camera2/CaptureResult)with the same frame number will be produced.

<br />

## Summary

|                                                                                                                                                        ### Constants                                                                                                                                                         ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [REASON_ERROR](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_ERROR) The[CaptureResult](https://developer.android.com/reference/android/hardware/camera2/CaptureResult)has been dropped this frame only due to an error in the framework.                                     |
| `int` | [REASON_FLUSHED](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_FLUSHED) The capture has failed due to a[CameraCaptureSession.abortCaptures](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession#abortCaptures())call from the application. |

|                                                                                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                                                                                ||
|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` long`                                                                                              | ` `[getFrameNumber](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getFrameNumber())`() ` Get the frame number associated with this failed capture.                                                                                                                                                                                                                                                                                       |
| ` `[String](https://developer.android.com/reference/java/lang/String)                                | ` `[getPhysicalCameraId](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getPhysicalCameraId())`() ` The physical camera device ID in case the capture failure comes from a[CaptureRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest)with configured physical camera streams for a logical camera.                                                                                                  |
| ` int`                                                                                               | ` `[getReason](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getReason())`() ` Determine why the request was dropped, whether due to an error or to a user action.                                                                                                                                                                                                                                                                       |
| ` `[CaptureRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest) | ` `[getRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getRequest())`() ` Get the request associated with this failed capture.                                                                                                                                                                                                                                                                                                    |
| ` int`                                                                                               | ` `[getSequenceId](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getSequenceId())`() ` The sequence ID for this failed capture that was returned by the[CameraCaptureSession.capture](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession#capture(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler))family of functions. |
| ` boolean`                                                                                           | ` `[wasImageCaptured](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#wasImageCaptured())`() ` Determine if the image was captured from the camera.                                                                                                                                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Constants

### REASON_ERROR

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

```
public static final int REASON_ERROR
```

The[CaptureResult](https://developer.android.com/reference/android/hardware/camera2/CaptureResult)has been dropped this frame only due to an error in the framework.

<br />

**See also:**

- [getReason()](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getReason())

Constant Value: 0 (0x00000000)  

### REASON_FLUSHED

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

```
public static final int REASON_FLUSHED
```

The capture has failed due to a[CameraCaptureSession.abortCaptures](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession#abortCaptures())call from the application.

<br />

**See also:**

- [getReason()](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#getReason())

Constant Value: 1 (0x00000001)

## Public methods

### getFrameNumber

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

```
public long getFrameNumber ()
```

Get the frame number associated with this failed capture.

Whenever a request has been processed, regardless of failed capture or success, it gets a unique frame number assigned to its future result/failed capture.

This value monotonically increments, starting with 0, for every new result or failure; and the scope is the lifetime of the[CameraDevice](https://developer.android.com/reference/android/hardware/camera2/CameraDevice).

<br />

<br />

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

### getPhysicalCameraId

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

```
public String getPhysicalCameraId ()
```

The physical camera device ID in case the capture failure comes from a[CaptureRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest)with configured physical camera streams for a logical camera.

<br />

|                                                                                                           Returns                                                                                                            ||
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | String The physical camera device ID of the respective failing output.`null`in case the capture request has no associated physical camera device. <br /> |

**See also:**

- [CaptureRequest.Builder.setPhysicalCameraKey(Key, T, String)](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder#setPhysicalCameraKey(android.hardware.camera2.CaptureRequest.Key<T>,%20T,%20java.lang.String))
- [OutputConfiguration.setPhysicalCameraId(String)](https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#setPhysicalCameraId(java.lang.String))  

### getReason

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

```
public int getReason ()
```

Determine why the request was dropped, whether due to an error or to a user action.

<br />

|                                                                                                                                   Returns                                                                                                                                   ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | int The reason code. Value is[REASON_ERROR](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_ERROR), or[REASON_FLUSHED](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_FLUSHED) <br /> |

**See also:**

- [REASON_ERROR](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_ERROR)
- [REASON_FLUSHED](https://developer.android.com/reference/android/hardware/camera2/CaptureFailure#REASON_FLUSHED)  

### getRequest

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

```
public CaptureRequest getRequest ()
```

Get the request associated with this failed capture.

Whenever a request is unsuccessfully captured, with[CameraCaptureSession.CaptureCallback.onCaptureFailed](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback#onCaptureFailed(android.hardware.camera2.CameraCaptureSession,%20android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CaptureFailure)), the`failed capture`'s`getRequest()`will return that`request`.

In particular,  

    cameraDevice.capture(someRequest, new CaptureCallback() {
         @Override
         void onCaptureFailed(CaptureRequest myRequest, CaptureFailure myFailure) {
             assert(myFailure.getRequest.equals(myRequest) == true);
         }
     };
     
<br />

<br />

<br />

|                                                                                 Returns                                                                                 ||
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [CaptureRequest](https://developer.android.com/reference/android/hardware/camera2/CaptureRequest) | The request associated with this failed capture. Never`null`. <br /> |

### getSequenceId

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

```
public int getSequenceId ()
```

The sequence ID for this failed capture that was returned by the[CameraCaptureSession.capture](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession#capture(android.hardware.camera2.CaptureRequest,%20android.hardware.camera2.CameraCaptureSession.CaptureCallback,%20android.os.Handler))family of functions.

The sequence ID is a unique monotonically increasing value starting from 0, incremented every time a new group of requests is submitted to the CameraDevice.

<br />

<br />

|                                             Returns                                              ||
|-------|-------------------------------------------------------------------------------------------|
| `int` | int The ID for the sequence of requests that this capture failure is the result of <br /> |

**See also:**

- [CameraCaptureSession.CaptureCallback.onCaptureSequenceCompleted(CameraCaptureSession, int, long)](https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession.CaptureCallback#onCaptureSequenceCompleted(android.hardware.camera2.CameraCaptureSession,%20int,%20long))  

### wasImageCaptured

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

```
public boolean wasImageCaptured ()
```

Determine if the image was captured from the camera.

If the image was not captured, no image buffers will be available. If the image was captured, then image buffers may be available.

<br />

<br />

|                                  Returns                                   ||
|-----------|-----------------------------------------------------------------|
| `boolean` | boolean True if the image was captured, false otherwise. <br /> |