Problem

If the code is getting the below error:

E/BufferQueueProducer(15428): [SurfaceTexture-0-15428-0] connect: already connected (cur=1 req=1)

Solution

You can try to change SurfaceView to TextureView.