public abstract class

CameraState.StateError

extends java.lang.Object

 java.lang.Object

↳androidx.camera.core.CameraState.StateError

Overview

Error that the camera has encountered.

The camera may report an error when it's in one of the following states: CameraState.Type.OPENING, CameraState.Type.OPEN, CameraState.Type.CLOSING and CameraState.Type.CLOSED.

CameraX attempts to recover from certain errors it encounters when opening the camera device, in these instances, the error is recoverable, otherwise, the error is critical.

When CameraX encounters a critical error, the developer and/or user must intervene to restore camera function. When the error is recoverable, the developer and/or user can still aid in the recovery process, as shown in the following table.

State Error Code Recoverable How to handle it
CameraState.Type.OPEN ERROR_STREAM_CONFIG No Make sure you set up your use cases correctly.
CameraState.Type.OPENING ERROR_CAMERA_IN_USE Yes Close the camera, or ask the user to close another camera app that is using the camera.
CameraState.Type.OPENING ERROR_MAX_CAMERAS_IN_USE Yes Close another open camera in the app, or ask the user to close another camera app that's using the camera.
CameraState.Type.OPENING ERROR_OTHER_RECOVERABLE_ERROR Yes N/A
CameraState.Type.CLOSING ERROR_CAMERA_DISABLED No Ask the user to enable the device's cameras.
CameraState.Type.CLOSING ERROR_CAMERA_FATAL_ERROR No Ask the user to reboot the device to restore camera function.
CameraState.Type.CLOSED ERROR_DO_NOT_DISTURB_MODE_ENABLED No Ask the user to disable "Do Not Disturb" mode, then open the camera again.

Summary

Constructors
publicStateError()

Methods
public static CameraState.StateErrorcreate(int error)

Creates a CameraState.StateError with an error code.

public static CameraState.StateErrorcreate(int error, java.lang.Throwable cause)

Creates a CameraState.StateError with an error code and a cause.

public abstract java.lang.ThrowablegetCause()

Returns a potential cause of this error.

public abstract intgetCode()

Returns the code of this error.

public CameraState.ErrorTypegetType()

Returns the type of this error.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public StateError()

Methods

public static CameraState.StateError create(int error)

Creates a CameraState.StateError with an error code.

A CameraState.StateError is not expected to be instantiated in normal operation.

public static CameraState.StateError create(int error, java.lang.Throwable cause)

Creates a CameraState.StateError with an error code and a cause.

A CameraState.StateError is not expected to be instantiated in normal operation.

public abstract int getCode()

Returns the code of this error.

The error's code is one of the following: CameraState.ERROR_CAMERA_IN_USE, CameraState.ERROR_MAX_CAMERAS_IN_USE, CameraState.ERROR_OTHER_RECOVERABLE_ERROR, CameraState.ERROR_STREAM_CONFIG, CameraState.ERROR_CAMERA_DISABLED, CameraState.ERROR_CAMERA_FATAL_ERROR and CameraState.ERROR_DO_NOT_DISTURB_MODE_ENABLED.

Returns:

The code of this error.

public abstract java.lang.Throwable getCause()

Returns a potential cause of this error.

Returns:

The cause of this error, or null if the cause was not supplied.

public CameraState.ErrorType getType()

Returns the type of this error.

An error can either be recoverable or critical.

Returns:

The type of this error