Condividi tramite


Camera.Open Method

Definition

Overloads

Open()
Obsolete.

Creates a new Camera object to access the first back-facing camera on the device.

Open(Int32)
Obsolete.

Creates a new Camera object to access a particular hardware camera.

Open()

Caution

deprecated

Creates a new Camera object to access the first back-facing camera on the device.

[Android.Runtime.Register("open", "()Landroid/hardware/Camera;", "")]
[System.Obsolete("deprecated")]
public static Android.Hardware.Camera? Open ();
[<Android.Runtime.Register("open", "()Landroid/hardware/Camera;", "")>]
[<System.Obsolete("deprecated")>]
static member Open : unit -> Android.Hardware.Camera

Returns

a new Camera object for the first back-facing camera, or null if there is no backfacing camera

Attributes

Remarks

Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null. Otherwise acts like the #open(int) call.

Java documentation for android.hardware.Camera.open().

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.

See also

Applies to

Open(Int32)

Caution

deprecated

Creates a new Camera object to access a particular hardware camera.

[Android.Runtime.Register("open", "(I)Landroid/hardware/Camera;", "")]
[System.Obsolete("deprecated")]
public static Android.Hardware.Camera? Open (int cameraId);
[<Android.Runtime.Register("open", "(I)Landroid/hardware/Camera;", "")>]
[<System.Obsolete("deprecated")>]
static member Open : int -> Android.Hardware.Camera

Parameters

cameraId
Int32

the hardware camera to access, between 0 and #getNumberOfCameras()-1.

Returns

a new Camera object, connected, locked and ready for use.

Attributes

Exceptions

if opening the camera fails (for example, if the camera is in use by another process or device policy manager has disabled the camera).

Remarks

Creates a new Camera object to access a particular hardware camera. If the same camera is opened by other applications, this will throw a RuntimeException.

You must call #release() when you are done using the camera, otherwise it will remain locked and be unavailable to other applications.

Your application should only have one Camera object active at a time for a particular hardware camera.

Callbacks from other methods are delivered to the event loop of the thread which called open(). If this thread has no event loop, then callbacks are delivered to the main application event loop. If there is no main application event loop, callbacks are not delivered.

<p class="caution"><b>Caution:</b> On some devices, this method may take a long time to complete. It is best to call this method from a worker thread (possibly using android.os.AsyncTask) to avoid blocking the main application UI thread.

Java documentation for android.hardware.Camera.open(int).

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.

See also

Applies to