You need to initialize TextureView
before opening a camera.
TextureView
is for displaying the image from camera on the device.
However, you cannot use it unless the texture is ready, either because the screen is currently off or it is initializing.
You should check mTextureView.isAvailable()
before opening your camera. Else you will mTextureView.setSurfaceTextureListener()
.
And open your camera in the callback method onSurfaceTextureListener
.
Before opening your camera you should check for a camera permission first.