Hi,
I am trying to set a camera preview in a custom SurfaceView but I get an exception each time I execute the initialization method.
Below is the code for camera preview initialization:
private void init(Context context)
{
setFocusable(true);
mRecording = false;
fileRW = new FileReaderWriter();
frameCount = 0;
if(mCamera == null)
{
mCamera = Camera.open();
}
Parameters parameters = mCamera.getParameters();
parameters.setPictureFormat(PixelFormat.JPEG);
mCamera.setParameters(parameters);
try {
mCamera.setPreviewDisplay(surfaceHolder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mCamera.startPreview();
}
the line `mCamera.setPreviewDisplay(surfaceHolder); throws an exception (setPreviewDisplay failed) each time I try to execute the method.
Does anyone know what could be wrong? I would really appreciate any of your help.
Thanks!`