public void stopCamera() {
   if (camera != null) {
     preview.stopCameraPreview();
     preview.setCamera(null, null);
     camera.release();
     camera = null;
   }
 }