public interface 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

addCameraPresenceListener

default void addCameraPresenceListener(
    @NonNull Executor executor,
    @NonNull CameraPresenceListener listener
)

Adds a listener for changes in camera presence.

The listener will be notified when cameras are added to or removed from the set of devices that can be used by CameraX. This list of "usable" cameras has already been processed by any configured CameraSelector limiters and compatibility filters.

Important Note on Synchronization: To prevent race conditions, this method immediately invokes CameraPresenceListener.onCamerasAdded once on the provided executor with a Set containing all cameras that are currently available. This guarantees that the listener's state is synchronized with the provider's state at the moment of registration.

This listener reports on persistent hardware changes and does not fire for temporary, recoverable errors, such as when a camera is in use by another application.

hasCamera

abstract boolean hasCamera(@NonNull 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.

Returns
boolean

true if the device has at least one available camera, otherwise false.

removeCameraPresenceListener

default void removeCameraPresenceListener(@NonNull CameraPresenceListener listener)

Removes a previously registered camera presence listener.

Once removed, the listener will no longer receive updates. If the listener was not previously registered, this method is a no-op.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-25 UTC.