Code example for SurfaceHolder

Methods: getSurface

0
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
        /* 
         * If your preview can change or rotate, take care of those events here. 
         * Make sure to stop the preview before resizing or reformatting it. 
         */ 
        if (mHolder.getSurface() == null){
          // preview surface does not exist 
          return; 
        } 
 
        // stop preview before making changes 
        try { 
            mCamera.stopPreview();
        } catch (Exception e){
          // ignore: tried to stop a non-existent preview 
        } 
 
        try { 
            // Hard code camera surface rotation 90 degs to match Activity view in portrait 
            mCamera.setDisplayOrientation(90);