Example usage for android.content Intent ACTION_DEVICE_STORAGE_LOW

List of usage examples for android.content Intent ACTION_DEVICE_STORAGE_LOW

Introduction

In this page you can find the example usage for android.content Intent ACTION_DEVICE_STORAGE_LOW.

Prototype

String ACTION_DEVICE_STORAGE_LOW

To view the source code for android.content Intent ACTION_DEVICE_STORAGE_LOW.

Click Source Link

Document

Broadcast Action: A sticky broadcast that indicates low storage space condition on the device

This is a protected intent that can only be sent by the system.

Usage

From source file:com.konker.konkersensors.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.//from w w w  .j a v a  2 s .c o  m
 *
 * 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();

    // 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.
    BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
    BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);
    barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());

    barcodeFactory.setOnNewBarcodeListener(new BarcodeTrackerFactory.OnNewBarcodeListener() {

        @Override
        public void onNewItem(Barcode item) {
            Intent data = new Intent();
            data.putExtra(BarcodeObject, item);
            setResult(CommonStatusCodes.SUCCESS, data);
            finish();
        }
    });

    if (!barcodeDetector.isOperational()) {
        // 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.
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // 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();
}

From source file:ch.hearc.drunksum.DrunkSumActivity.java

/**
 * Creates and starts the camera.  Note that this uses a higher resolution in comparison
 * to other detection examples to enable the ocr detector to detect small text samples
 * at long distances./*from  w  w  w. j a v a2  s  .c om*/
 *
 * 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();

    // Create the TextRecognizer
    TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();

    // Set the TextRecognizer's Processor.
    textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));

    // Check if the TextRecognizer is operational.
    if (!textRecognizer.isOperational()) {
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // Create the mCameraSource using the TextRecognizer.
    mCameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer)
            .setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(1280, 1024)
            .setRequestedFps(30.0f).setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
            .setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null).build();
}

From source file:com.google.android.gms.oem.bolti.keszlet.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./*from w w w .ja  va 2 s  .c o m*/
 *
 * 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();

    // 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.
    BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
    BarcodeDetector barcodeDetector2 = new BarcodeDetector.Builder(context).build();
    BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);

    //barcodeDetector.setProcessor(
    //        new MultiProcessor.Builder<>(barcodeFactory).build());

    barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {
        @Override
        public void release() {
        }

        @Override
        public void receiveDetections(Detector.Detections<Barcode> detections) {
            final SparseArray<Barcode> barcodes = detections.getDetectedItems();
            //MediaPlayer mp = MediaPlayer.create(this, R.raw.sound);
            if (barcodes.size() != 0) {

                //  mp.start();
                barcode3 = barcodes.valueAt(0).displayValue;
                Log.w(TAG, barcode3);
                Intent data = new Intent();
                data.putExtra(BarcodeObject, barcode3);
                setResult(CommonStatusCodes.SUCCESS, data);
                finish();
            }
        }

    });

    if (!barcodeDetector.isOperational()) {
        // 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.
        Log.w(TAG, "A Detektor fggsgei nem teljesthetk");

        // 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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }

    }

    // 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();

}

From source file:com.example.sherrychuang.splitsmart.Activity.OcrCaptureActivity.java

/**
 * Creates and starts the camera.  Note that this uses a higher resolution in comparison
 * to other detection examples to enable the ocr detector to detect small text samples
 * at long distances.//from  w w  w . ja v a2  s  .  com
 *
 * 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();

    // TODO: Create the TextRecognizer
    TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
    // TODO: Set the TextRecognizer's Processor.
    textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));
    // TODO: Check if the TextRecognizer is operational.
    if (!textRecognizer.isOperational()) {
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }
    // TODO: Create the mCameraSource using the TextRecognizer.
    mCameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer)
            .setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(1280, 1024)
            .setRequestedFps(15.0f).setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
            .setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null).build();
}

From source file:it.acutus.utilitylibrarycode.barcode.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.//from  w ww.ja  va  2s.c  o  m
 *
 * 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();

    // 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.
    BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
    BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay, this);
    barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());

    if (!barcodeDetector.isOperational()) {
        // 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.
        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) {
            Log.w(TAG, "Face detector dependencies cannot be downloaded due to low device storage");
        }
    }

    // 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();
}

From source file:com.purelink.cluelin.barcodescanner.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.//from   w  ww .j  a v  a2s. c om
 * <p>
 * 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, boolean code128) {
    Context context = getApplicationContext();

    // 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.

    //        change original code to detect only CODE_128 type barcode

    BarcodeDetector barcodeDetector;

    if (code128) {
        barcodeDetector = new BarcodeDetector.Builder(context).setBarcodeFormats(Barcode.CODE_128).build();
    } else {
        barcodeDetector = new BarcodeDetector.Builder(context).build();
    }

    // this is original code.
    /*BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);*/

    BarcodeTrackerFactory barcodeFactory;

    {
        barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay,
                new BarcodeGraphicTracker.BarcodeAutoDetectionListener() {

                    @Override
                    public void onNewBarcodeDetection(Barcode barcode) {
                        if (barcode != null) {
                            Intent data = new Intent();
                            data.putExtra(BarcodeObject, barcode);
                            //setResult(CommonStatusCodes.SUCCESS, data);
                            if (getParent() == null) {
                                setResult(CommonStatusCodes.SUCCESS, data);
                            } else {
                                getParent().setResult(CommonStatusCodes.SUCCESS, data);
                            }
                            finish();
                        }
                        Log.d("BarcodeDetected", barcode.displayValue);
                    }
                });
    }

    barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());

    if (!barcodeDetector.isOperational()) {
        // 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.
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // 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(3840, 2160)
            .setRequestedFps(60.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();
}

From source file:de.schildbach.wallet.ui.AlertDialogsFragment.java

private boolean handleCatchAll() {
    final Intent stickyIntent = activity.registerReceiver(null,
            new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));
    if (stickyIntent != null) {
        handler.post(new Runnable() {
            @Override//  w w  w  .j a  v  a 2  s  .  c  o m
            public void run() {
                if (isAdded())
                    createLowStorageAlertDialog().show();
            }
        });
        return true;
    }
    return false;
}

From source file:com.ecsm.android.readForMe.activities.OcrCaptureActivity.java

/**
 * Creates and starts the camera.  Note that this uses a higher resolution in comparison
 * to other detection examples to enable the ocr detector to detect small text samples
 * at long distances./*  w  w  w.ja va2 s .c o  m*/
 * <p>
 * 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();
    // A text recognizer is created to find text.  An associated multi-processor instance
    // is set to receive the text recognition results, track the text, and maintain
    // graphics for each text block on screen.  The factory is used by the multi-processor to
    // create a separate tracker instance for each text block.
    TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();
    textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay, mResultTextHolder));

    if (!textRecognizer.isOperational()) {
        // Note: The first time that an app using a Vision 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 text,
        // barcodes, 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.
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // Creates and starts the camera.  Note that this uses a higher resolution in comparison
    // to other detection examples to enable the text recognizer to detect small pieces of text.
    mCameraSource = new CameraSource.Builder(getApplicationContext(), textRecognizer)
            .setFacing(CameraSource.CAMERA_FACING_BACK).setStatusView(mStatusView)
            .setRequestedPreviewSize(1280, 1024).setRequestedFps(2.0f)
            .setFlashMode(useFlash ? Camera.Parameters.FLASH_MODE_TORCH : null)
            .setFocusMode(autoFocus ? Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE : null).build();
}

From source file:piuk.blockchain.android.ui.WalletActivity.java

private void checkLowStorageAlert() {
    final Intent stickyIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));
    if (stickyIntent != null) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setTitle(R.string.wallet_low_storage_dialog_title);
        builder.setMessage(R.string.wallet_low_storage_dialog_msg);
        builder.setPositiveButton(R.string.wallet_low_storage_dialog_button_apps,
                new DialogInterface.OnClickListener() {
                    public void onClick(final DialogInterface dialog, final int id) {
                        startActivity(//from www . j  a  v a2s .  c o m
                                new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));
                        finish();
                    }
                });
        builder.setNegativeButton(R.string.button_dismiss, null);
        builder.show();
    }
}

From source file:com.google.android.gms.samples.vision.face.multitracker.MultiTrackerActivity.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.//from www  .  ja  va2s .  c om
 */
private void createCameraSource() {

    Context context = getApplicationContext();

    // A face detector is created to track faces.  An associated multi-processor instance
    // is set to receive the face detection results, track the faces, and maintain graphics for
    // each face on screen.  The factory is used by the multi-processor to create a separate
    // tracker instance for each face.
    //        FaceDetector faceDetector = new FaceDetector.Builder(context).build();
    //        FaceTrackerFactory faceFactory = new FaceTrackerFactory(mGraphicOverlay);
    //        faceDetector.setProcessor(
    //                new MultiProcessor.Builder<>(faceFactory).build());

    // 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.
    BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
    scanner.addObserver(sender);

    //        Log.i("sa.IP", "value:" + sa.retrieve("IP"));
    //        Log.i("sa.Port", "value:" + sa.retrieve("Port"));
    sender = XMLRPCSender.getInstance();
    Log.i("sender", "IP" + sender.ip);

    BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay,
            new GraphicTracker.Callback() {
                @Override
                public void onFound(String barcodeValue) {
                    Scan scan = new Scan(barcodeValue);
                    scanner.insertScan(scan);
                    try {
                        Log.d(TAG, "Barcode in Multitracker = " + barcodeValue);
                        Log.i("Sender IP", "Value:" + sender.ip);
                        TextView bcTV = (TextView) findViewById(R.id.barcodeTV);
                        bcTV.setText(barcodeValue + "\n" + bcTV.getText());
                        Button allB = (Button) findViewById(R.id.allButton);
                        Button listB = (Button) findViewById(R.id.listButton);
                        Button singleB = (Button) findViewById(R.id.singleButton);

                        //RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.main);
                        //remoteViews.setTextViewText(R.id.allButton, scanner.totalScanCount().toString());
                        allB.setText(scanner.totalScanCount());
                        listB.setText(scanner.listScanCount());
                        singleB.setText("1");
                    } catch (Exception ex) {
                        Log.e(ex.getMessage(), "Expected error: ");
                    }

                }
            });
    //        MultiProcessor<Barcode> barcodeMultiProcessor = new MultiProcessor.Builder<>(barcodeFactory).build();
    //        barcodeDetector.setProcessor(barcodeMultiProcessor);
    barcodeDetector.setProcessor(new MultiProcessor.Builder<>(barcodeFactory).build());

    // A multi-detector groups the two detectors together as one detector.  All images received
    // by this detector from the camera will be sent to each of the underlying detectors, which
    // will each do face and barcode detection, respectively.  The detection results from each
    // are then sent to associated tracker instances which maintain per-item graphics on the
    // screen.
    MultiDetector multiDetector = new MultiDetector.Builder()
            //.add(faceDetector)
            .add(barcodeDetector).build();

    if (!multiDetector.isOperational()) {
        // 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.
        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, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }

    // 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.
    //        mCameraSource = new CameraSource.Builder(getApplicationContext(), multiDetector)
    //                .setFacing(CameraSource.CAMERA_FACING_BACK)
    //                .setRequestedPreviewSize(1600, 1024)
    //                .setRequestedFps(15.0f)
    //                .build();
    CameraSource.Builder builder = new CameraSource.Builder(getApplicationContext(), barcodeDetector)
            .setFacing(CameraSource.CAMERA_FACING_BACK).setRequestedPreviewSize(2560, 1440)
            .setRequestedFps(15.0f);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        builder = builder.setAutoFocusEnabled(true);
    }
    mCameraSource = builder.build();
}