code: private void startCameraSource() throws SecurityException {
          // check that the device has play services available.
          int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
                  getActivity().getApplicationContext());
          if (code != ConnectionResult.SUCCESS) {
              Dialog dlg =
                      GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), code, RC_HANDLE_GMS);
              dlg.show();
          }
  
          if (mCameraSource != null) {
              try {
                  mPreview.start(mCameraSource, mGraphicOverlay);
              } catch (IOException e) {
                  Log.e("BARCODE-SCANNER", "Unable to start camera source.", e);
                  mCameraSource.release();
                  mCameraSource = null;
                  if (mListener != null)
                      mListener.onBarcodeScanningFailed("could not create camera source");
              }
          }
      }
docs: Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
  (e.g., because onResume was called before the camera source was created), this will be called
  again when the camera source is created.