Android.Hardware.Camera.SetPreviewDisplay Method
Sets the Android.Views.Surface to be used for live preview.

Syntax

[Android.Runtime.Register("setPreviewDisplay", "(Landroid/view/SurfaceHolder;)V", "")]
public void SetPreviewDisplay (Android.Views.ISurfaceHolder holder)

Parameters

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

Exceptions

TypeReason
Java.IO.IOExceptionif the method fails (for example, if the surface is unavailable or unsuitable).

Remarks

Sets the Android.Views.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 Camera.SetPreviewTexture(Android.Graphics.SurfaceTexture).

The Android.Views.ISurfaceHolder must already contain a surface when this method is called. If you are using Android.Views.SurfaceView, you will need to register a Android.Views.ISurfaceHolderCallback with Android.Views.ISurfaceHolder.AddCallback(Android.Views.ISurfaceHolderCallback) and wait for Android.Views.ISurfaceHolderCallback.SurfaceCreated(Android.Views.ISurfaceHolder) before calling setPreviewDisplay() or starting preview.

This method must be called before Camera.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.

[Android Documentation]

Requirements

Namespace: Android.Hardware
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1