Camera.SetPreviewTexture(SurfaceTexture) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
deprecated
Sets the SurfaceTexture
to be used for live preview.
[Android.Runtime.Register("setPreviewTexture", "(Landroid/graphics/SurfaceTexture;)V", "")]
[System.Obsolete("deprecated")]
public void SetPreviewTexture (Android.Graphics.SurfaceTexture? surfaceTexture);
[<Android.Runtime.Register("setPreviewTexture", "(Landroid/graphics/SurfaceTexture;)V", "")>]
[<System.Obsolete("deprecated")>]
member this.SetPreviewTexture : Android.Graphics.SurfaceTexture -> unit
Parameters
- surfaceTexture
- SurfaceTexture
the SurfaceTexture
to which the preview
images are to be sent or null to remove the current preview surface
texture
- Attributes
Exceptions
if the method fails (for example, if the surface texture is unavailable or unsuitable).
Remarks
Sets the 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 #setPreviewDisplay
.
This method must be called before #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 SurfaceTexture#getTimestamp()
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.
Java documentation for android.hardware.Camera.setPreviewTexture(android.graphics.SurfaceTexture)
.
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.