public final class BarcodeReader extends ServiceConnector implements IBarcodeReader
ServiceConnector.InternalServiceConnection
ACTION_BIND_V2, SERVICES_PACKAGE
Modifier and Type | Method and Description |
---|---|
protected android.content.Intent |
getBindIntent()
Can be overrided to connect to other services
|
static IBarcodeReader |
getInstance(android.content.Context context)
Return a global instance of Barcode Reader, which is the default implementation of
IBarcodeReader , and instantiate it if needed. |
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.
|
protected java.lang.String |
getServiceName()
Must be overrided to provide service class name used for binding.
|
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.
|
protected void |
onServiceReady(android.os.IBinder service)
Internal callback when service is connected.
|
protected void |
onServiceUnbinded()
Internal callback when service is disconnected.
|
void |
registerBarcodeReaderListener(IBarcodeReaderResultListener listener)
Register a new listener for BarcodeReader event sent during the process.
|
void |
start(BarcodeReaderInputData inputData)
Start a barcode reader according to the parameters filled in inputData field.
|
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.
|
connect, connectSync, disconnect, ensureServiceIsReady, getContext, isConnected
public static IBarcodeReader getInstance(android.content.Context context)
IBarcodeReader
, and instantiate it if needed.
Be aware that only one instance will be created for the whole application, so the associated
context should not be a component which could be destroyed at some point, ie. an Activity.
Passing the Application
to this method is preferred over other context types.
context
- A valid context to initialize the instance.protected android.content.Intent getBindIntent()
ServiceConnector
getBindIntent
in class ServiceConnector
public java.util.List<PreviewSize> getPreviewSizes(int cameraType) throws IngenicoException
Usage example:
IBarcodeReader
barcodeReader = 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 (PreviewSize
size : previewSizes) { if ((size.getWidth() == 640) && (size.getHeight() == 480)) { expectedSizeIsAvailable = true; break; } } if (expectedSizeIsAvailable) { // Start barcode reader with a 640x480 preview size }
getPreviewSizes
in interface IBarcodeReader
IngenicoException
- when could not retrieve the preview sizespublic java.util.List<java.lang.Integer> getSymbols()
getSymbols
in interface IBarcodeReader
public void start(@NonNull BarcodeReaderInputData inputData) throws IngenicoException
start
in interface IBarcodeReader
inputData
- barcode reader parametersIngenicoException
- when the start barcode reader call failspublic void start(@NonNull BarcodeReaderInputData inputData, @NonNull android.view.Surface inputPreview) throws IngenicoException
start
in interface IBarcodeReader
inputData
- barcode reader parametersinputPreview
- use TextureView
to display a content stream come from camera
previewIngenicoException
- when the start barcode reader call failspublic void stop() throws IngenicoException
stop
in interface IBarcodeReader
IngenicoException
- when the stop barcode reader call fails (not started)public void registerBarcodeReaderListener(@NonNull IBarcodeReaderResultListener listener)
IBarcodeReader
registerBarcodeReaderListener
in interface IBarcodeReader
listener
- barcode reader listenerpublic void unregisterBarcodeReaderListener(@NonNull IBarcodeReaderResultListener listener)
IBarcodeReader
unregisterBarcodeReaderListener
in interface IBarcodeReader
listener
- barcode reader listenerprotected java.lang.String getServiceName()
ServiceConnector
getServiceName
in class ServiceConnector
protected void onServiceReady(android.os.IBinder service)
ServiceConnector
onServiceReady
in class ServiceConnector
protected void onServiceUnbinded()
ServiceConnector
onServiceUnbinded
in class ServiceConnector