CameraProvider
public
interface
CameraProvider
| androidx.camera.core.CameraProvider |
A CameraProvider provides basic access to a set of cameras such as querying for camera
existence or information.
A device might have multiple cameras. According to the applications' design, they might
need to search for a suitable camera which supports their functions. A CameraProvider
allows the applications to check whether any camera exists to fulfill the requirements or to
get CameraInfo instances of all cameras to retrieve the camera information.
Summary
Public methods | |
|---|---|
abstract
List<CameraInfo>
|
getAvailableCameraInfos()
Returns |
abstract
boolean
|
hasCamera(CameraSelector cameraSelector)
Checks whether this provider supports at least one camera that meets the requirements from a
|
Public methods
getAvailableCameraInfos
public abstract List<CameraInfo> getAvailableCameraInfos ()
Returns CameraInfo instances of the available cameras.
While iterating through all the available CameraInfo, if one of them meets some
predefined requirements, a CameraSelector that uniquely identifies its camera
can be retrieved using CameraInfo.getCameraSelector(), which can then be used to bind
use cases to that camera.
| Returns | |
|---|---|
List<CameraInfo> |
A list of CameraInfo instances for the available cameras.
|
hasCamera
public abstract boolean hasCamera (CameraSelector cameraSelector)
Checks whether this provider supports at least one camera that meets the requirements from a
CameraSelector.
If this method returns true, then the camera selector can be used to bind
use cases and retrieve a Camera instance.
| Parameters | |
|---|---|
cameraSelector |
CameraSelector: the CameraSelector that filters available cameras. |
| Returns | |
|---|---|
boolean |
true if the device has at least one available camera, otherwise false. |
| Throws | |
|---|---|
CameraInfoUnavailableException |
if unable to access cameras, perhaps due to insufficient permissions. |