private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) {
   // Bitmap isn't used yet -- will be used soon
   if (handler == null) {
     savedResultToShow = result;
   } else {
     if (result != null) {
       savedResultToShow = result;
     }
     if (savedResultToShow != null) {
       Message message = Message.obtain(handler, IConstants.DECODE_SUCCEDED, savedResultToShow);
       handler.sendMessage(message);
     }
     savedResultToShow = null;
   }
 }
  public void surfaceDestroyed(SurfaceHolder holder) {
    if (getCameraManager() == null) {
      Log.e(TAG, "stopScan: scan already stopped");
      return;
    }

    if (handler != null) {
      handler.quitSynchronously();
      handler = null;
    }

    // inactivityTimer.onPause();
    ambientLightManager.stop();
    // beepManager.close();
    getCameraManager().closeDriver();
    setCameraManager(null);

    if (!hasSurface) {
      SurfaceHolder surfaceHolder = this.getHolder();
      surfaceHolder.removeCallback(this);
    }
  }
 public void restartPreviewAfterDelay(long delayMS) {
   if (handler != null) {
     handler.sendEmptyMessageDelayed(IConstants.RESTART_PREVIEW, delayMS);
   }
 }