Code example for SurfaceHolder

Methods: addCallback, setFixedSize, setType

0
		mCamera = camera;
 
		// Install a SurfaceHolder.Callback so we get notified when the 
		// underlying surface is created and destroyed. 
		mHolder = getHolder();
		mHolder.addCallback(this);
		// deprecated setting, but required on Android versions prior to 3.0 
		mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
 
		mHolder.setFixedSize(100, 100);
	} 
 
	public void surfaceCreated(SurfaceHolder holder) {
		// The Surface has been created, now tell the camera where to draw the 
		// preview. 
		try { 
			mCamera.setPreviewDisplay(holder);
			mCamera.startPreview();
		} catch (IOException e) {
			Log.d("DG_DEBUG", "Error setting camera preview: " + e.getMessage());
		}