src/android/src/gmvScanner/BarcodeCaptureActivity.java
/**
     * Creates and starts the camera.  Note that this uses a higher resolution in comparison
     * to other detection examples to enable the barcode detector to detect small barcodes
     * at long distances.
     *
     * Suppressing InlinedApi since there is a check that the minimum version is met before using
     * the constant.
     */
Creates and starts the camera.  Note that this uses a higher resolution in comparison
to other detection examples to enable the barcode detector to detect small barcodes
at long distances.

Suppressing InlinedApi since there is a check that the minimum version is met before using
the constant.
Creates and starts the camera . Note that this uses a higher resolution in comparison to other detection examples to enable the barcode detector to detect small barcodes at long distances . Suppressing InlinedApi since there is a check that the minimum version is met before using the constant .
@SuppressLint("InlinedApi")
    private void createCameraSource(boolean autoFocus, boolean useFlash) {
        Context context = getApplicationContext();
        int detectionType = 0;
        if(DetectionTypes == 0) {
            detectionType = (Barcode.CODE_39|Barcode.DATA_MATRIX);
        } else if(DetectionTypes == 1234) {
        } else {
            detectionType = DetectionTypes;
        }
        BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).setBarcodeFormats(detectionType).build();
        BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay, this);
        barcodeDetector.setProcessor(
                new MultiProcessor.Builder<>(barcodeFactory).build());
        if (!barcodeDetector.isOperational()) {
             isOperational() can be used to check if the required native libraries are currently
             available.  The detectors will automatically become operational once the library
             downloads complete on device.
            Log.w(TAG, "Detector dependencies are not yet available.");
             Check for low storage.  If there is low storage, the native library will not be
             downloaded, so detection will not become operational.
            IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
            boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
            if (hasLowStorage) {
                Toast.makeText(this, getResources().getIdentifier("low_storage_error", "string", getPackageName()), Toast.LENGTH_LONG).show();
                Log.w(TAG, getString(getResources().getIdentifier("low_storage_error", "string", getPackageName())));
            }
        }
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;
         Creates and starts the camera.  Note that this uses a higher resolution in comparison
         to other detection examples to enable the barcode detector to detect small barcodes
         at long distances.
        CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector)
                .setFacing(CameraSource.CAMERA_FACING_BACK)
                .setRequestedPreviewSize(1600, 1024)
                .setRequestedFps(15.0f);
         make sure that auto focus is an available option
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            builder = builder.setFocusMode(
                    autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null);
        }
        mCameraSource = builder
                .setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
                .build();
    }
@ SuppressLint ( "InlinedApi" ) private void createCameraSource ( boolean autoFocus , boolean useFlash ) { Context context = getApplicationContext ( ) ; int detectionType = 0 ; if ( DetectionTypes == 0 ) { detectionType = ( Barcode . CODE_39 | Barcode . DATA_MATRIX ) ; } else if ( DetectionTypes == 1234 ) { } else { detectionType = DetectionTypes ; } BarcodeDetector barcodeDetector = new BarcodeDetector . Builder ( context ) . setBarcodeFormats ( detectionType ) . build ( ) ; BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory ( mGraphicOverlay , this ) ; barcodeDetector . setProcessor ( new MultiProcessor . Builder < > ( barcodeFactory ) . build ( ) ) ; if ( ! barcodeDetector . isOperational ( ) ) { Log . w ( TAG , "Detector dependencies are not yet available." ) ; IntentFilter lowstorageFilter = new IntentFilter ( Intent . ACTION_DEVICE_STORAGE_LOW ) ; boolean hasLowStorage = registerReceiver ( null , lowstorageFilter ) != null ; if ( hasLowStorage ) { Toast . makeText ( this , getResources ( ) . getIdentifier ( "low_storage_error" , "string" , getPackageName ( ) ) , Toast . LENGTH_LONG ) . show ( ) ; Log . w ( TAG , getString ( getResources ( ) . getIdentifier ( "low_storage_error" , "string" , getPackageName ( ) ) ) ) ; } } Display display = getWindowManager ( ) . getDefaultDisplay ( ) ; Point size = new Point ( ) ; display . getSize ( size ) ; int width = size . x ; int height = size . y ; CameraSource . Builder builder = new CameraSource . Builder ( getApplicationContext ( ) , barcodeDetector ) . setFacing ( CameraSource . CAMERA_FACING_BACK ) . setRequestedPreviewSize ( 1600 , 1024 ) . setRequestedFps ( 15.0f ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . ICE_CREAM_SANDWICH ) { builder = builder . setFocusMode ( autoFocus ? Camera . Parameters . FOCUS_MODE_CONTINUOUS_PICTURE : null ) ; } mCameraSource = builder . setFlashMode ( useFlash ? Camera . Parameters . FLASH_MODE_TORCH : null ) . build ( ) ; }
Creates and starts the camera.
Creates and starts the camera .
// A barcode detector is created to track barcodes.  An associated multi-processor instance // is set to receive the barcode detection results, track the barcodes, and maintain // graphics for each barcode on screen.  The factory is used by the multi-processor to // create a separate tracker instance for each barcode. // Note: The first time that an app using the barcode or face API is installed on a // device, GMS will download a native libraries to the device in order to do detection. // Usually this completes before the app is run for the first time.  But if that // download has not yet completed, then the above call will not detect any barcodes // and/or faces. // // isOperational() can be used to check if the required native libraries are currently // available.  The detectors will automatically become operational once the library // downloads complete on device. // Check for low storage.  If there is low storage, the native library will not be // downloaded, so detection will not become operational. // Creates and starts the camera.  Note that this uses a higher resolution in comparison // to other detection examples to enable the barcode detector to detect small barcodes // at long distances. // make sure that auto focus is an available option