Compartir a través de


CameraManager.AvailabilityCallback.OnPhysicalCameraUnavailable Method

Definition

A previously-available physical camera has become unavailable for use.

[Android.Runtime.Register("onPhysicalCameraUnavailable", "(Ljava/lang/String;Ljava/lang/String;)V", "GetOnPhysicalCameraUnavailable_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)]
public virtual void OnPhysicalCameraUnavailable (string cameraId, string physicalCameraId);
[<Android.Runtime.Register("onPhysicalCameraUnavailable", "(Ljava/lang/String;Ljava/lang/String;)V", "GetOnPhysicalCameraUnavailable_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=30)>]
abstract member OnPhysicalCameraUnavailable : string * string -> unit
override this.OnPhysicalCameraUnavailable : 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 previously-available physical camera has become unavailable for use.

By default, all of the physical cameras of a logical multi-camera are unavailable if the logical camera itself is unavailable. No availability callbacks will be called for any of the physical cameras of its parent logical multi-camera, when #onCameraUnavailable for the logical multi-camera is invoked.

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.onPhysicalCameraUnavailable(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