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

# CameraDevice.CameraDeviceSetup

*** ** * ** ***

` public static abstract class CameraDevice.CameraDeviceSetup `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

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

<br />

*** ** * ** ***

CameraDeviceSetup is a limited representation of `https://developer.android.com/reference/android/hardware/camera2/CameraDevice` that can be used to query device specific information which would otherwise need a CameraDevice instance. This class can be constructed without calling `https://developer.android.com/reference/android/hardware/camera2/CameraManager#openCamera(java.lang.String,%20android.hardware.camera2.CameraDevice.StateCallback,%20android.os.Handler)` and paying the latency cost of CameraDevice creation. Use `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraDeviceSetup(java.lang.String)` to get an instance of this class.

Can only be instantiated for camera devices for which `https://developer.android.com/reference/android/hardware/camera2/CameraManager#isCameraDeviceSetupSupported(java.lang.String)` returns true.

<br />

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraManager#isCameraDeviceSetupSupported(java.lang.String)`
- `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraDeviceSetup(java.lang.String)`

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder` | ` https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#createCaptureRequest(int)(int templateType) ` Create a `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder` for new capture requests, initialized with a template for target use case. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#getId()() ` Get the ID of this camera device. |
| ` abstract https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics` | ` https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#getSessionCharacteristics(android.hardware.camera2.params.SessionConfiguration)(https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration sessionConfig) ` Get camera characteristics for a particular session configuration for this camera device. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)(https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration config) ` Checks whether a particular `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` is supported by the camera device. |
| ` abstract void` | ` https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#openCamera(java.util.concurrent.Executor,%20android.hardware.camera2.CameraDevice.StateCallback)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback callback) ` Utility function to forward the call to `https://developer.android.com/reference/android/hardware/camera2/CameraManager#openCamera(java.lang.String,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraDevice.StateCallback)`. |

### 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*.

## Public methods

### createCaptureRequest

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

```
public abstract CaptureRequest.Builder createCaptureRequest (int templateType)
```

Create a `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder` for new capture requests, initialized with a template for target use case.

The settings are chosen to be the best options for the specific camera device, so it is not recommended to reuse the same request for a different camera device; create a builder specific for that device and template and override the settings as desired, instead.

Supported if `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#INFO_SESSION_CONFIGURATION_QUERY_VERSION` is at least `https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM`. If less or equal to `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`, this function throws an `https://developer.android.com/reference/java/lang/UnsupportedOperationException`.

<br />

<br />

| Parameters ||
|---|---|
| `templateType` | `int`: An enumeration selecting the use case for this request. Not all template types are supported on every device. See the documentation for each template type for details. Value is one of the following: - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_PREVIEW` - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_STILL_CAPTURE` - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_RECORD` - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_VIDEO_SNAPSHOT` - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_ZERO_SHUTTER_LAG` - `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#TEMPLATE_MANUAL` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder` | a builder for a capture request, initialized with default settings for that template, and no output streams. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraAccessException` | if the querying the camera device failed or there has been a fatal error |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the templateType is not supported by this device |

### getId

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

```
public abstract String getId ()
```

Get the ID of this camera device.

This matches the ID given to `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraDeviceSetup(java.lang.String)` to instantiate this object.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the ID for this camera device. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraIdList()`

### getSessionCharacteristics

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

```
public abstract CameraCharacteristics getSessionCharacteristics (SessionConfiguration sessionConfig)
```

Get camera characteristics for a particular session configuration for this camera device.

The camera characteristics returned by this method are different from those returned from `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraCharacteristics(java.lang.String)`. The characteristics returned here reflect device capabilities more accurately if the device were to be configured with `sessionConfig`. The keys that may get updated are listed in `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#getAvailableSessionCharacteristicsKeys()`.

Other than that, the characteristics returned here can be used in the same way as those returned from `https://developer.android.com/reference/android/hardware/camera2/CameraManager#getCameraCharacteristics(java.lang.String)`.

To optimize latency, the application can call this method before acquiring valid `https://developer.android.com/reference/android/view/SurfaceView`, `https://developer.android.com/reference/android/graphics/SurfaceTexture`, `https://developer.android.com/reference/android/media/MediaRecorder`, `https://developer.android.com/reference/android/media/MediaCodec`, or `https://developer.android.com/reference/android/media/ImageReader` surfaces. For `https://developer.android.com/reference/android/view/SurfaceView`, `https://developer.android.com/reference/android/graphics/SurfaceTexture`, `https://developer.android.com/reference/android/media/MediaRecorder`, and `https://developer.android.com/reference/android/media/MediaCodec`, the application can call `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(android.util.Size,%20java.lang.Class<T>)`. For `https://developer.android.com/reference/android/media/ImageReader`, the application can call `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20android.util.Size)`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20int,%20android.util.Size)`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20android.util.Size,%20long)`, or `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20int,%20android.util.Size,%20long)`. The `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` can then be created using the OutputConfiguration objects and be used for this function. To create the CameraCaptureSession, the application still needs to make sure all output surfaces are added via `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#addSurface(android.view.Surface)` with the exception of deferred surfaces for `https://developer.android.com/reference/android/view/SurfaceView` and `https://developer.android.com/reference/android/graphics/SurfaceTexture`.

<br />

<br />

| Parameters ||
|---|---|
| `sessionConfig` | `SessionConfiguration`: The session configuration for which characteristics are fetched. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics` | CameraCharacteristics specific to a given session configuration. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraAccessException` | if the camera device is no longer connected or has encountered a fatal error |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the session configuration is invalid or if `https://developer.android.com/reference/android/hardware/camera2/CameraDevice.CameraDeviceSetup#isSessionConfigurationSupported(android.hardware.camera2.params.SessionConfiguration)` returns `false` for the provided `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` |

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#getAvailableSessionCharacteristicsKeys()`

### isSessionConfigurationSupported

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

```
public abstract boolean isSessionConfigurationSupported (SessionConfiguration config)
```

Checks whether a particular `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` is supported by the camera device.

This method performs a runtime check of a given `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration`. The result confirms whether or not the `SessionConfiguration`, **including the parameters specified via `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration#setSessionParameters(android.hardware.camera2.CaptureRequest)`** , can be used to create a camera capture session using `https://developer.android.com/reference/android/hardware/camera2/CameraDevice#createCaptureSession(android.hardware.camera2.params.SessionConfiguration)`.

This method is supported if the `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#INFO_SESSION_CONFIGURATION_QUERY_VERSION` is at least `https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM`. If less or equal to `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE`, this function throws `https://developer.android.com/reference/java/lang/UnsupportedOperationException`.

Although this method is much faster than creating a new capture session, it can still take a few milliseconds per call. Applications should therefore not use this method to explore the entire space of supported session combinations.

Instead, applications should use this method to query whether combinations of certain features are supported. `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#INFO_SESSION_CONFIGURATION_QUERY_VERSION` provides the list of feature combinations the camera device will reliably report.

If this function returns `true` for a particular stream combination, the camera device supports concurrent captures on all of the streams in the same CaptureRequest, with two exceptions below where concurrent captures are not supported:

- Supported stream combinations with exclusive dynamic range profiles as specified by `https://developer.android.com/reference/android/hardware/camera2/params/DynamicRangeProfiles#getProfileCaptureRequestConstraints(long)`.
- Supported combinations of 'default' mode and 'max resolution' mode streams for devices with ULTRA_HIGH_RESOLUTION_SENSOR capability.

For other cases where concurrent captures of a stream combination are not supported, this function returns `false`.

**IMPORTANT:**

- If feature support can be queried via `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics`, applications should directly use that route rather than calling this function as: (1) using `CameraCharacteristics` is more efficient, and (2) querying a feature explicitly deemed unsupported by CameraCharacteristics may throw a `https://developer.android.com/reference/java/lang/IllegalArgumentException`.
- To minimize `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` creation latency due to its dependency on output surfaces, the application can call this method before acquiring valid `https://developer.android.com/reference/android/view/SurfaceView`, `https://developer.android.com/reference/android/graphics/SurfaceTexture`, `https://developer.android.com/reference/android/media/MediaRecorder`, `https://developer.android.com/reference/android/media/MediaCodec`, or `https://developer.android.com/reference/android/media/ImageReader` surfaces. For `https://developer.android.com/reference/android/view/SurfaceView`, `https://developer.android.com/reference/android/graphics/SurfaceTexture`, `https://developer.android.com/reference/android/media/MediaRecorder`, and `https://developer.android.com/reference/android/media/MediaCodec`, the application can call `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(android.util.Size,%20java.lang.Class<T>)`. For `https://developer.android.com/reference/android/media/ImageReader`, the application can call `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20android.util.Size)`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20int,%20android.util.Size)`, `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20android.util.Size,%20long)`, or `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#OutputConfiguration(int,%20int,%20android.util.Size,%20long)`. The `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration` can then be created using the OutputConfiguration objects and be used to query whether it's supported by the camera device. To create the CameraCaptureSession, the application still needs to make sure all output surfaces are added via `https://developer.android.com/reference/android/hardware/camera2/params/OutputConfiguration#addSurface(android.view.Surface)` with the exception of deferred surfaces for `https://developer.android.com/reference/android/view/SurfaceView` and `https://developer.android.com/reference/android/graphics/SurfaceTexture`.

<br />

<br />

| Parameters ||
|---|---|
| `config` | `SessionConfiguration`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the given session configuration is supported by the camera device, `false` otherwise. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraAccessException` | if the camera device is no longer connected or has encountered a fatal error |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the session configuration is invalid, including, if it contains certain non-supported features queryable via CameraCharacteristics. |

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#INFO_SESSION_CONFIGURATION_QUERY_VERSION`
- `https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration`
- `https://developer.android.com/reference/android/media/ImageReader`

### openCamera

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

```
public abstract void openCamera (Executor executor, 
                CameraDevice.StateCallback callback)
```

Utility function to forward the call to `https://developer.android.com/reference/android/hardware/camera2/CameraManager#openCamera(java.lang.String,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraDevice.StateCallback)`. This function simply calls `CameraManager.openCamera` for the cameraId for which this class was constructed. All semantics are consistent with `CameraManager.openCamera`.   

Requires `https://developer.android.com/reference/android/Manifest.permission#CAMERA`

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor which will be used when invoking the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `callback` | `CameraDevice.StateCallback`: The callback which is invoked once the camera is opened. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CameraAccessException` | if the camera is disabled by device policy, has been disconnected, or is being used by a higher-priority camera API client. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if cameraId, the callback or the executor was null, or the cameraId does not match any currently or previously available camera device. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if the application does not have permission to access the camera |

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraManager#openCamera(java.lang.String,%20java.util.concurrent.Executor,%20android.hardware.camera2.CameraDevice.StateCallback)`