I have tested my application on the Android SDK on everything from 1.5 to 2.2 and the camera code in my activity works fine. Running it on a device with 2.1 is also working.
The problem is that the width and height passed by the surfaceChanged method is not a preview size supported.
So if you wanna set the preview size (parameters.setPreviewSize), you need to set a supported preview size. The method getPreviewSize() returns an available preview size. So your surfaceChanged method can be like that:
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Camera.Parameters parameters = camera.getParameters();
Size pSize = camera.getParameters().getPreviewSize();
Log.d(TAG, "Setting preview size: " + pSize.width + " x " + pSize.height);
parameters.setPreviewSize(pSize.width, pSize.height);
camera.setParameters(parameters);
camera.startPreview();
}
You can also get a list of the supported preview sizes using the method getSupportedPreviewSizes() available from android api version 5.