com.amarula.barcodescanner.sdk

## Class BarcodeScannerConnection

- java.lang.Object
- - com.amarula.barcodescanner.sdk.BarcodeScannerConnection

-     public class BarcodeScannerConnection
      extends java.lang.Object

  Manages the connection to `BarcodeScannerService`.

  {link bindToBarcodeScannerService()} start the connection process (bind) to {link BarcodeScannerService} while `unbindFromBarcodeScannerService()` disconnect from it.

  While connected you can use:

  - `scanOneBarcode()`: To trigger the scanning of a single barcode
  - `scanMultipleBarcodes()`: To trigger the scanning of multiple barcodes (Service doesen't stop scanning after the first positive result)
  - `stopScanning()`: To abort the current scanning

  Bind to the barcode scanner service only if needed: the service keeps "warm" the hardware for scanning from binding till unbind consuming more power so Applications must to bind to the scanner only when needed:

  - If connecting from an Activity, bind on onResume(), unbind on onPause()
  - If connecting from a Service, bind on need and unbind on Screen Off

  Since the preparation and release of {link BarcodeScannerService} are long time tasks, you can use `startCachedBarcodeScannerService()` to bind to the scannig service.
  Doing this, {link BarcodeScannerService} will be started to cache it's state with a timeout and {link IBarcodeScannerService.release()} will not be called on unbind. In this way it is the service itself that is in charge of releasing it's state when no clients are connected after a timeout.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BarcodeScannerConnection(Context ctx, BarcodeScannerConnectionInterface cb)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bindToBarcodeScannerService()`
    `int` | `scanMultipleBarcodes()`
    `int` | `scanOneBarcode()`
    `void` | `startCachedBarcodeScannerService()`
    `void` | `stopScanning()`
    `void` | `unbindFromBarcodeScannerService()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BarcodeScannerConnection

          public BarcodeScannerConnection(Context ctx,
                                          BarcodeScannerConnectionInterface cb)

  - ### Method Detail

    - #### bindToBarcodeScannerService

          public void bindToBarcodeScannerService()

    - #### startCachedBarcodeScannerService

          public void startCachedBarcodeScannerService()

    - #### unbindFromBarcodeScannerService

          public void unbindFromBarcodeScannerService()

    - #### stopScanning

          public void stopScanning()

    - #### scanMultipleBarcodes

          public int scanMultipleBarcodes()

    - #### scanOneBarcode

          public int scanOneBarcode()