# RetryPolicy.ExecutionState

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/RetryPolicy.java+class:androidx.camera.core.RetryPolicy.ExecutionState) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

*** ** * ** ***


```
@ExperimentalRetryPolicy
interface RetryPolicy.ExecutionState
```

<br />

*** ** * ** ***

Provides insights into the current execution state of the camera initialization process.

The ExecutionState empowers app developers to make informed decisions about retry strategies and fine-tune timeout settings. It also facilitates comprehensive app-level logging for tracking initialization success/failure rates and overall camera performance.

Key use cases:

- Determining whether to retry initialization based on specific error conditions.
- Logging detailed execution information for debugging and analysis.
- Monitoring retry success/failure rates to identify potential issues.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#STATUS_CAMERA_UNAVAILABLE() = 2` Indicates that the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraProvider` failed to initialize due to an unavailable camera. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#STATUS_CONFIGURATION_FAIL() = 1` Indicates that initialization of CameraX failed due to invalid customization options within the provided `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraXConfig`. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#STATUS_UNKNOWN_ERROR() = 0` Indicates that the initialization encountered an unknown error. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#getCause()()` Gets the cause that occurred during the task execution, if any. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#getExecutedTimeInMillis()()` Gets the total execution time of the initialization task in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#getNumOfAttempts()()` Indicates the total number of attempts made to initialize the camera, including the current attempt. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/RetryPolicy.ExecutionState#getStatus()()` Retrieves the status of the most recently completed initialization attempt. |

## Constants

### STATUS_CAMERA_UNAVAILABLE

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val STATUS_CAMERA_UNAVAILABLE = 2: Int
```

Indicates that the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraProvider` failed to initialize due to an unavailable camera. This error suggests a temporary issue with the device's cameras, and retrying may resolve the issue.

### STATUS_CONFIGURATION_FAIL

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val STATUS_CONFIGURATION_FAIL = 1: Int
```

Indicates that initialization of CameraX failed due to invalid customization options within the provided `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraXConfig`. This error typically indicates a problem with the configuration settings and may require developer attention to resolve.

Possible Causes:

- Incorrect or incompatible settings within the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraXConfig`.
- Conflicting options that prevent successful initialization.
- Missing or invalid values for essential configuration parameters.

To troubleshoot: Please see `getCause().getMessage()` for details, and review configuration of the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraXConfig` to identify potential errors or inconsistencies in the customization options.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/lifecycle/ProcessCameraProvider#configureInstance(androidx.camera.core.CameraXConfig)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraXConfig.Builder` |   |

### STATUS_UNKNOWN_ERROR

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val STATUS_UNKNOWN_ERROR = 0: Int
```

Indicates that the initialization encountered an unknown error. This error may be transient, and retrying may resolve the issue.

## Public functions

### getCause

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getCause(): Throwable?
```

Gets the cause that occurred during the task execution, if any.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?` | The cause that occurred during the task execution, or null if there was no error. |

### getExecutedTimeInMillis

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getExecutedTimeInMillis(): Long
```

Gets the total execution time of the initialization task in milliseconds.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The total execution time of the initialization task in milliseconds. |

### getNumOfAttempts

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getNumOfAttempts(): Int
```

Indicates the total number of attempts made to initialize the camera, including the current attempt. The count starts from 1.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The total number of attempts made to initialize the camera. |

### getStatus

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getStatus(): Int
```

Retrieves the status of the most recently completed initialization attempt.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The status code representing the outcome of the initialization. |