I have a question regarding the preview callbacks with Android 4.0.x.
I set up a camera, create a surface to display camera image on previewCallback
-event. Everything works fine.
But with Android 4.0.x neither onPreviewCallback
is called nor onPreviewCallbackWithBuffer
.
Is there a workaround for this issue?
I want to take a screen shot and do not want to use the takePicture()
-way because it freezes the live image for a short-time.
You must to call setPreviewCallback in surfaceChanged method, not only in surfaceCreated.
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
if (mHolder.getSurface() == null){
return;
}
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
try {
mCamera.setPreviewCallback(this);
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d(TAG, "Error starting camera preview: " + e.getMessage());
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With