Code example for Camera.Parameters

Methods: getPreviewFormat, getSupportedFocusModes, getSupportedPictureSizes, getSupportedPreviewSizes, setFocusMode, setPictureFormat, setPictureSize, setPreviewSize

0
				return; 
			} 
		} 
 
		Camera.Parameters parameters = camera.getParameters();
		int format = parameters.getPreviewFormat();		
 
		List<Camera.Size> supportedSizes = parameters.getSupportedPreviewSizes();
 
		if(isPreviewSizeSupported(supportedSizes) == true){
			parameters.setPreviewSize(width,height);
		} 
		else 
			parameters.setPreviewSize(supportedSizes.get(0).width, supportedSizes.get(0).height);			
 
		parameters.setPictureFormat(ImageFormat.JPEG);
		//parameters.setPictureSize(width, height); 
 
		if (mPreviewSize == null) {
			// h and w get inverted on purpose 
			mPreviewSize = getOptimalSize(parameters.getSupportedPictureSizes(), width > height ? width
					: height, width > height ? height : width);
		} 
 
		parameters.setPictureSize(mPreviewSize.width, mPreviewSize.height);
 
		Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
				.getDefaultDisplay();
 
		switch (display.getRotation()) {
		case Surface.ROTATION_0:
			angle = 90;
			break; 
		case Surface.ROTATION_90:
			angle = 0;
			break; 
		case Surface.ROTATION_180:
			angle = 270;
			break; 
		case Surface.ROTATION_270:
			angle = 180;
			break; 
		default: 
			throw new AssertionError("Wrong surface rotation value");
		} 
		setDisplayOrientation(parameters, angle);
 
		List<String> focusModes = parameters.getSupportedFocusModes();
		if (focusModes != null && focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
			parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
		} 
 
		try { 
			camera.setParameters(parameters);
		} catch (Exception e) {