Share via


CameraManager.AvailabilityCallback.OnPhysicalCameraAvailable Method

Definition

A physical camera has become available for use again.

[Android.Runtime.Register("onPhysicalCameraAvailable", "(Ljava/lang/String;Ljava/lang/String;)V", "GetOnPhysicalCameraAvailable_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)]
public virtual void OnPhysicalCameraAvailable (string cameraId, string physicalCameraId);
[<Android.Runtime.Register("onPhysicalCameraAvailable", "(Ljava/lang/String;Ljava/lang/String;)V", "GetOnPhysicalCameraAvailable_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)>]
abstract member OnPhysicalCameraAvailable : string * string -> unit
override this.OnPhysicalCameraAvailable : string * string -> unit

Parameters

cameraId
String

The unique identifier of the logical multi-camera.

physicalCameraId
String

The unique identifier of the physical camera.

Attributes

Remarks

A physical camera has become available for use again.

By default, all of the physical cameras of a logical multi-camera are available, so #onPhysicalCameraAvailable is not called for any of the physical cameras of a logical multi-camera, when #onCameraAvailable for the logical multi-camera is invoked. However, if some specific physical cameras are unavailable to begin with, #onPhysicalCameraUnavailable may be invoked after #onCameraAvailable.

If android.content.pm.ApplicationInfo#targetSdkVersion targetSdkVersion &lt; android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE, opening a logical camera disables the #onPhysicalCameraAvailable and #onPhysicalCameraUnavailable callbacks for its physical cameras. For example, if app A opens the camera device:

<ul>

<li>All apps subscribing to ActivityCallback get #onCameraUnavailable.</li>

<li>No app (including app A) subscribing to ActivityCallback gets #onPhysicalCameraAvailable or #onPhysicalCameraUnavailable, because the logical camera is unavailable (some app is using it).</li>

</ul>

If android.content.pm.ApplicationInfo#targetSdkVersion targetSdkVersion &ge; android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE:

<ul>

<li>A physical camera status change will trigger #onPhysicalCameraAvailable or #onPhysicalCameraUnavailable even after the logical camera becomes unavailable. A #onCameraUnavailable call for a logical camera doesn't reset the physical cameras' availability status. This makes it possible for an application opening the logical camera device to know which physical camera becomes unavailable or available to use.</li>

<li>Similar to android.os.Build.VERSION_CODES#TIRAMISU Android 13 and earlier, the logical camera's #onCameraAvailable callback implies all of its physical cameras' status become available. #onPhysicalCameraUnavailable will be called for any unavailable physical cameras upon the logical camera becoming available.</li>

</ul>

Given the pipeline nature of the camera capture through android.hardware.camera2.CaptureRequest, there may be frame drops if the application requests images from a physical camera of a logical multi-camera and that physical camera becomes unavailable. The application should stop requesting directly from an unavailable physical camera as soon as #onPhysicalCameraUnavailable is received, and also be ready to robustly handle frame drop errors for requests targeting physical cameras, since those errors may arrive before the unavailability callback.

The default implementation of this method does nothing.

Java documentation for android.hardware.camera2.CameraManager.AvailabilityCallback.onPhysicalCameraAvailable(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to