Code example for SurfaceHolder

Methods: addCallback, setType

0
        */ 
 
        // 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);
    } 
 
    public void surfaceCreated(SurfaceHolder holder) {
        // The Surface has been created, now tell the camera where to draw the preview. 
        try { 
            mCamera.setPreviewDisplay(holder);
        } catch (IOException e) {
            Log.d("DBG", "Error setting camera preview: " + e.getMessage());
        } 
    } 
 
    public void surfaceDestroyed(SurfaceHolder holder) {