I'm trying to use a SurfaceView in Android to hold a Camera preview. The documentation tells me that I need to call startPreview in the surfaceCreated callback for the surface holder. I'm trying to set the callback like so
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:
SurfaceHolder.Callback has no constructors.
I'm confused why this doesn't work when something like this does:
Thread(Runnable() {
fun run() {
...
}
})