Our application displays a camera preview and it seems to work fine on all phones except for the Motorola Droid where we get a runtime exception when we set the camera parameters:
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:611)
at com.highwaynorth.andrometer.CameraPreviewSurfaceView.surfaceChanged(CameraPreviewSurfaceView.java:57)
at android.view.SurfaceView.updateWindow(SurfaceView.java:460)
at android.view.SurfaceView.dispatchDraw(SurfaceView.java:287)
at android.view.ViewGroup.drawChild(ViewGroup.java:1525)
Here is the code for surfaceChanged() which is mostly taken from APIDemos
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(w, h);
parameters.setPictureFormat(PixelFormat.JPEG);
parameters.setPreviewFormat(PixelFormat.YCbCr_422_SP);
parameters.setPreviewFrameRate(1);
mCamera.setParameters(parameters);
mCamera.startPreview();
}
Does anyone know what is wrong with how we are setting the parameters that would be causing the exception on the Motorola Droid?