I googled and got the below solution.. Replace your surfacechanged method with below one
private static Method getSupportedPreviewSizes = null;
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
try {
Camera.Parameters parameters = camera.getParameters();
Integer version = Integer.parseInt(Build.VERSION.SDK);
if (version >= Build.VERSION_CODES.ECLAIR) {
try {
getSupportedPreviewSizes = Parameters.class.getMethod(
"getSupportedPreviewSizes", (Class[]) null);
/* success, this is a newer device */
} catch (NoSuchMethodException nsme) {
/* failure, must be older device */
}
Object supportedFormats = getSupportedPreviewSizes.invoke(
parameters, (Object[]) null);
List<Size> sizes;
if (supportedFormats instanceof List<?>) {
sizes = (List<Camera.Size>) supportedFormats;// params.getSupportedPreviewSizes();
Size optimalSize = getOptimalPreviewSize(sizes, w, h);
parameters.setPreviewSize(optimalSize.width,
optimalSize.height);
}
} else {
parameters.setPreviewSize(100, 100);
}
parameters.setPictureSize(320, 480);
camera.setParameters(parameters);
camera.startPreview();
} catch (Exception e) {
e.printStackTrace();
}
}