I am trying to render camera preview using SurfaceTexture. I read the document but unable to understand how it works.
Can anyone provide one sample example(very basic one) or link which uses SurfaceTexture to preview camera. I googled this but not found what I am looking for.
Thanks in advance.
If you want to use the Camera with TextureSurface you can implement
SurfaceTextureListenerinterface. You’ll have to implement 4 methods:1)
onSurfaceTextureAvailable– Here you setup your camera2)
onSurfaceTextureSizeChanged– In your case, the Android’s camera will handle this method3)
onSurfaceTextureDestroyed– Here you destroy all camera stuff.4)
onSurfaceTextureUpdated– Update your texture here when you have something to change!Check the example below:
Two more things: Don’t forget to add the camera permissions in your project’s manifest and the
SurfaceTextureis available from API 11.