Code example for Camera: Taking pictures with the camera

Methods: autoFocusgetParameterssetParameterstakePicture

0
		mCamera.startPreview();
	} 
 
	// 拍照 
	public void tokenPicture() { 
		mCamera.autoFocus(this);
		setPreviewSize(); 
		mCamera.takePicture(mShutterCallback, mPictureCallbackRaw, mPictureCallbackJpeg);
	} 
 
	// 自动对焦 
	@Override 
	public void onAutoFocus(boolean success, Camera camera) {
		//TODO: 
	} 
	 
	public void release() { 
		if (mMediaRecorder != null) {
			//mMediaRecorder.stop(); 
			mMediaRecorder.release();
			mMediaRecorder = null;
		} 
		if (mCamera != null) {
			mCamera.stopPreview();
			mCamera.release();
			mCamera = null;
		} 
	} 
 
	// 设置预览大小 
	private void setPreviewSize() { 
		Camera.Parameters parameters = mCamera.getParameters();
		parameters.setPictureFormat(PixelFormat.JPEG);
		parameters.setJpegQuality(parameters.getJpegQuality());
		parameters.setZoom(parameters.getZoom());
		parameters.setPictureSize(1280, 720);
		parameters.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
		parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
		mCamera.setParameters(parameters);
	} 
	 
	public void startVideo(SurfaceHolder holder) {
		if (mCamera != null) {
			mCamera.autoFocus(this);
Contextual code suggestions in your IDE  Get Codota for Java