Workflow and integration guide
After adding the Standalone SDK to your project and setting up the required permissions, you can start with your implementation. This section explains how to create and manage the PgManager, subscribe to connection events, and initiate pairing with the scanner.
Create a PgManager instance
The PgManager is the central entry point for working with the Standalone SDK. Always use the application context when creating it, and keep the instance alive for as long as your app communicates with the scanner.
val pgManager = PgManager(applicationContext)
Notice
Best practice: Keep the PgManager instance in a foreground service. Destroying the instance will disconnect the device from the scanner.
Start pairing the scanner with the Standalone SDK
After the setup is complete, the next step is to establish a connection between the device and the scanner.To initiate pairing, call:
pgManager.startPairing()
This method call is equivalent to:
pgManager.startPairing(
PgPairingParams.Scan2Pair(
advertisingName = null, // A random 10-character string will be generated
timeout = DEFAULT_TIMEOUT // Default timeout is 60 seconds
)
)If needed, you can manually define advertisingName and timeout parameters.
Before calling startPairing(), make sure that your app is subscribed to the scanner connection state listener.
This listener provides callbacks for key connection events, including:
Device connected to the scanner.
Device disconnected from the scanner.
Scanner searching state (providing a pairing QR code).
General connection status updates
You can subscribe to the listener as follows:
pgManager.subscribeToScannerConnectionStatus(this)
One of the callback methods is:
override fun onScannerSearching(pairingQrCode: Bitmap) {
// Your implementation once searching for device is started
// Display the provided QR code in your UI
// The user scans it with the ProGlove scanner to start pairing
}Here, pairingQrCode: Bitmap represents the QR code that the scanner must scan to initiate pairing.
Once pgManager.startPairing() is called, the onScannerSearching(pairingQrCode) callback provides the generated QR code. When the scanner successfully scans this code, pairing begins on both sides (scanner and device).
After successful pairing, the onScannerConnected() callback confirms that the connection has been established between the device and the scanner.
Subscribing to scan events
You can also subscribe to receive barcode scan events directly in your app. To do this, call:
pgManager.subscribeToScans(this)
A standard barcode scan callback looks like this:
override fun onBarcodeScanned(barcodeScanResult: BarcodeScanResult) {
// Your implementation once barcode is scanned
}barcodeScanResult is a wrapper containing the scanned barcode’s content and symbology.
Additionally, you can handle special barcodes — such as configuration QR codes — using:
override fun onSpecialBarcodeScanned(barcodeScanResult: PgScannerConfigurationChangeResult) {
// Your implementation once special barcode (QR code with scanner configuration) is scanned
}This callback provides the result of a configuration barcode scan. Using this method is optional, as it generally provides limited data relevant for user-facing features.