I am trying to use SurfaceView in Android to preview the camera. The documentation tells me that I need to call startPreview on the surfaceCreated callback for the surface holder. I am trying to set a callback like this
this.surface!!.holder!!.addCallback(SurfaceHolder.Callback() {
fun surfaceChanged(holder: SurfaceHolder, format: Int,
width: Int, height: Int) {
}
fun surfaceCreated(holder: SurfaceHolder) {
}
fun surfaceDestroyed(holder: SurfaceHolder) {
}
})
However, I get the error message:
SurfaceHolder.Callback has no constructors.
I am confused why this does not work when something like this:
Thread(Runnable() {
fun run() {
...
}
})
source
share