Android.Hardware.Camera.SetPreviewTexture Method
Sets the Android.Graphics.SurfaceTexture to be used for live preview.

Syntax

[Android.Runtime.Register("setPreviewTexture", "(Landroid/graphics/SurfaceTexture;)V", "")]
public void SetPreviewTexture (Android.Graphics.SurfaceTexture surfaceTexture)

See Also

Android.Media.MediaActionSound
Android.Graphics.SurfaceTexture
Android.Views.TextureView

Parameters

surfaceTexture
the Android.Graphics.SurfaceTexture to which the preview images are to be sent or null to remove the current preview surface texture

Exceptions

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

Remarks

Sets the Android.Graphics.SurfaceTexture 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 texture can be re-set without harm. Setting a preview surface texture will un-set any preview surface that was set via Camera.SetPreviewDisplay(Android.Views.ISurfaceHolder).

This method must be called before Camera.StartPreview. The one exception is that if the preview surface texture 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 texture may not otherwise change while preview is running.

The timestamps provided by Android.Graphics.SurfaceTexture.Timestamp for a SurfaceTexture set as the preview texture have an unspecified zero point, and cannot be directly compared between different cameras or different instances of the same camera, or across multiple runs of the same program.

If you are using the preview data to create video or still images, strongly consider using Android.Media.MediaActionSound to properly indicate image capture or recording start/stop to the user.

[Android Documentation]

Requirements

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