public interface IBarcodeReader
Usage example for a EAN/UPC/I25 barcode reader with 640x480 preview size on the front camera and a time out delay of 30s:
IBarcodeReaderbarcodeReader = BarcodeReader.getInstance(context);BarcodeReaderInputDatainputData =BarcodeReaderInputData.builder() .setCameraType(CameraTypes.FRONT) .setBarcodeSymbols(Arrays.asList(BarcodeSymbols.EAN,BarcodeSymbols.UPC,BarcodeSymbols.I25)) .setPreviewWidth(640) .setPreviewHeight(480) .setCaptureWidth(640) .setCaptureHeight(480) .setTimeOut(30) .build(); barcodeReader.start(inputData);
Usage example for a QR/DATAMATRIX/CODABLOCK barcode reader with 4:3 preview ratio on the back camera and without any time out delay:
IBarcodeReaderbarcodeReader = BarcodeReader.getInstance(context); // Get the first 4:3 preview ratio available on the back cameraPreviewSizeexpectedRatioSize = null;List<PreviewSize> previewSizes = barcodeReader.getPreviewSizes(CameraTypes.BACK); for (PreviewSizesize : previewSizes) { if (Float.compare(size.getWidth() / (float) size.getHeight(), 4 / 3f) == 0) { expectedRatioSize = size; break; } } // Check 4:3 ratio preview size found if (expectedRatioSize != null) {BarcodeReaderInputDatainputData =BarcodeReaderInputData.builder() .setCameraType(CameraTypes.BACK) .setBarcodeSymbols(Arrays.asList(BarcodeSymbols.QR_CODE,BarcodeSymbols.DATAMATRIX,BarcodeSymbols.CODABLOCK)) .setPreviewWidth(expectedRatioSize.getWidth()) .setPreviewHeight(expectedRatioSize.getHeight()) .setCaptureWidth(expectedRatioSize.getWidth()) .setCaptureHeight(expectedRatioSize.getHeight()) .build(); barcodeReader.start(inputData); }
Usage example for a EAN/QR/CODABAR barcode reader with a portrait preview size on the front camera and a time out delay of 45s:
IBarcodeReaderbarcodeReader = BarcodeReader.getInstance(context); // Get the first preview size in portrait orientation available on the front cameraPreviewSizeexpectedPortraitSize = null;List<PreviewSize> previewSizes = barcodeReader.getPreviewSizes(CameraTypes.FRONT); for (PreviewSizesize : previewSizes) { if (size.getWidth() < size.getHeight()) { expectedPortraitSize = size; break; } } // Check preview size in portrait orientation found if (expectedPortraitSize != null) {BarcodeReaderInputDatainputData =BarcodeReaderInputData.builder() .setCameraType(CameraTypes.FRONT) .setBarcodeSymbols(Arrays.asList(BarcodeSymbols.EAN,BarcodeSymbols.QR_CODE,BarcodeSymbols.CODABAR)) .setPreviewWidth(expectedPortraitSize.getWidth()) .setPreviewHeight(expectedPortraitSize.getHeight()) .setCaptureWidth(expectedPortraitSize.getWidth()) .setCaptureHeight(expectedPortraitSize.getHeight()) .build(); barcodeReader.start(inputData); }
| Modifier and Type | Method and Description |
|---|---|
java.util.List<PreviewSize> |
getPreviewSizes(int cameraType)
Get the list of preview sizes supported by the service according the camera type selected on
the current device or payment terminal.
|
java.util.List<java.lang.Integer> |
getSymbols()
Get the list of symbols supported by the service according the barcode decoding library
selected on the current device or payment terminal.
|
void |
registerBarcodeReaderListener(IBarcodeReaderResultListener listener)
Register a new listener for BarcodeReader event sent during the process.
|
void |
start(BarcodeReaderInputData inputData)
Deprecated.
since 2.13.0, use
IBarcodeReader.start(BarcodeReaderInputData, Surface). |
void |
start(BarcodeReaderInputData inputData,
android.view.Surface inputPreview)
Start a barcode reader according to the parameters filled in inputData field.
|
void |
stop()
Stop the barcode reader process.
|
void |
unregisterBarcodeReaderListener(IBarcodeReaderResultListener listener)
Unregister an existing barcode reader listener.
|
java.util.List<PreviewSize> getPreviewSizes(int cameraType) throws IngenicoException
Usage example:
IBarcodeReaderbarcodeReader = BarcodeReader.getInstance(context); // Check that 640x480 preview size is available on the front camera boolean expectedSizeIsAvailable = false;List<PreviewSize> previewSizes = barcodeReader.getPreviewSizes(CameraTypes.FRONT); for (PreviewSizesize : previewSizes) { if ((size.getWidth() == 640) && (size.getHeight() == 480)) { expectedSizeIsAvailable = true; break; } } if (expectedSizeIsAvailable) { // Start barcode reader with a 640x480 preview size }
IngenicoException - when could not retrieve the preview sizesjava.util.List<java.lang.Integer> getSymbols()
@Deprecated void start(BarcodeReaderInputData inputData) throws IngenicoException
IBarcodeReader.start(BarcodeReaderInputData, Surface).inputData - barcode reader parametersIngenicoException - when the start barcode reader call failsvoid start(BarcodeReaderInputData inputData, android.view.Surface inputPreview) throws IngenicoException
inputData - barcode reader parametersinputPreview - use TextureView to display a content stream come from camera
previewIngenicoException - when the start barcode reader call failsvoid stop() throws IngenicoException
IngenicoException - when the stop barcode reader call fails (not started)void registerBarcodeReaderListener(IBarcodeReaderResultListener listener)
listener - barcode reader listenervoid unregisterBarcodeReaderListener(IBarcodeReaderResultListener listener)
listener - barcode reader listener