Condividi tramite


Camera.SetPreviewDisplay(ISurfaceHolder) Method

Definition

Caution

deprecated

Sets the Surface to be used for live preview.

[Android.Runtime.Register("setPreviewDisplay", "(Landroid/view/SurfaceHolder;)V", "")]
[System.Obsolete("deprecated")]
public void SetPreviewDisplay (Android.Views.ISurfaceHolder? holder);
[<Android.Runtime.Register("setPreviewDisplay", "(Landroid/view/SurfaceHolder;)V", "")>]
[<System.Obsolete("deprecated")>]
member this.SetPreviewDisplay : Android.Views.ISurfaceHolder -> unit

Parameters

holder
ISurfaceHolder

containing the Surface on which to place the preview, or null to remove the preview surface

Attributes

Exceptions

if the method fails (for example, if the surface is unavailable or unsuitable).

Remarks

Sets the Surface to be used for live preview. Either a surface or surface texture is necessary for preview, and preview is necessary to take pictures. The same surface can be re-set without harm. Setting a preview surface will un-set any preview surface texture that was set via #setPreviewTexture.

The SurfaceHolder must already contain a surface when this method is called. If you are using android.view.SurfaceView, you will need to register a SurfaceHolder.Callback with SurfaceHolder#addCallback(SurfaceHolder.Callback) and wait for SurfaceHolder.Callback#surfaceCreated(SurfaceHolder) before calling setPreviewDisplay() or starting preview.

This method must be called before #startPreview(). The one exception is that if the preview surface is not set (or set to null) before startPreview() is called, then this method may be called once with a non-null parameter to set the preview surface. (This allows camera setup and surface creation to happen in parallel, saving time.) The preview surface may not otherwise change while preview is running.

Java documentation for android.hardware.Camera.setPreviewDisplay(android.view.SurfaceHolder).

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