This project contains the core of the AndroidPOS project. AndroidPOS is the porting on Android of the Datalogic JavaPOS library. Implements the UPOS standard (v 1.14) to allow Android POS/POE/tablet to communicate with Datalogic scanners and scales.
Communication is only supported via USB-OEM, USB-COM is included but it does not work on all devices.
The Android module :
- allows to listen for scan or weight events.
- allows Firmware comparison and update.
- allows statistics retrieval from device (both UPOS and Avalanche format).
- allows to send commands to devices.
A sample app, is available here.
Add in your root build.gradle at the end of repositories:
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }Add the following dependency to your gradle file:
dependencies { implementation 'com.github.datalogic:androidpos-core:0.1.1-alpha' }The standard setup for a scanner is as follows: Integrating a scanner is very easy. The code is almost the same of JavaPOS.
Instantiate a Scanner object, open it, and claim the port:
Scanner scanner = new Scanner(); scanner.open(logicalName, context); scanner.claim(requestListener);requestListener is an interface, responsible for handling the success or the failure of the port claiming.
The user must explicitly grant a dedicated permission, to allow the application to claim a port.
To register for data events it is necessary to register an EventListener, to set to false the auto disable and to enable data events and device communication:
scanner.addEventListener(listener, EventCallback.EventType.Data); scanner.setAutoDisable(false); scanner.setDataEventEnabled(true); scanner.setDeviceEnabled(true);All of this is fully UPOS compliant and identical to JavaPOS.
To close the communication, disable communication and remove data listener, release the port and close the device:
Scanner.setDataEventEnabled(false); Scanner.setAutoDisable(true); Scanner.removeEventListener(listener, EventCallback.EventType.Data) Scanner.setDeviceEnabled(false); scanner.release(); scanner.close();All of this is fully UPOS compliant and identical to JavaPOS.
The standard setup for a scale is as follows:
Instantiate a Scale object, open it, and claim the port:
Scale scale = new Scale(); scale.open(logicalName, context); scale.claim(requestListener);requestListener is an interface, responsible for handling the success or the failure of the port claiming.
The user must explicitly grant a dedicated permission to allow the application to claim a port.
To get weight, enable data events and ask for the weight to the scale:
scale.setDataEventEnabled(true); scale.readWeight(result, timeout);All of this is fully UPOS compliant and identical to JavaPOS.
To close the communication release the port and close the device:
scale.release(); scale.close();The library can be configured using a configuration file, exactly as JavaPOS and UPOS requirements. The only difference is the format of the file: json. In the asset folder of the project an apos.json file must be edited. The sample application provides an example of this file.
The following table lists a set of Datalogic devices tested via USB-OEM.
| Device | Lifecycle | Get Weight | Receive labels | Retrieve statistics | Firmware comparison | Firmware upgrade |
|---|---|---|---|---|---|---|
| QuickScan QD2590 | V | NS | V | V | V | V |
| Gryphon GD4590 | V | NS | V | V | V | V |
| Gryphon GD4520 | V | NS | V | V | V | V |
| PowerScan PD9630 | V* | NS | V* | V* | V* | - |
| PowerScan PD9530 | V | NS | V | V | V | V |
| Magellan 9800i | V | V | V | V | V | - |
(*)- requires an external power plug.
The following Android devices has been used to test:
- HP Engage one prime,
- Galaxy Tab A.
Tested Android versions are:
- Android 8,
- Android 9.