Scan2Pair
The Scan2Pair feature allows you to connect your scanner to INSIGHT Mobile by scanning the pairing barcode.
Besides using the Scan2Pair feature that is built in INSIGHT Mobile, you can initiate the Scan2Pair barcode screen using the SDK or Intent.
To explore the Scan2Pair feature’s functionalities via Intent or SDK API, or to further test the API, check out the Sample app’s code in our GitHub repository.
Pair with scanner using SDK
To start the pairing process, call startPairing()
on your PgManager
reference. The Insight Mobile app will take over and show the paring QR code. After your device was paired with a scanner or the process was canceled by the user, your Activity
will be brought back to the foreground. Your registered IScannerOutput
implementations will be called according to the updated scanner state.
Pair from the pinned Activity
If your app runs inside the Android’s pinned application mode, you have to use startPairingFromPinnedActivity(activity)
.
activity
must be an Activity running in the currently pinned task. Pairing works the same as with startPairing()
but works in the pinning mode.
pgManager.connect(this.applicationContext)
should still be called with the ApplicationContext. That way a scanner stays connected regardless of the Lifecycle of a single Activity.
Starting the pairing from a Background Task: Only startPairing()
is able to work from a Service’s Context.
Pair with scanner using Intent
Use the following code snippet to invoke the PairingActivity with the startActivity call from within your business application:
val component = ComponentName(“de.proglove.connect”,“de.proglove.coreui.activities.PairingActivity”) val launchIntent = Intent() launchIntent.setComponent(component) startActivity(launchIntent)
Note
On starting the PairingActivity
, the scanner will be disconnected (which means the user has to pair again). However, you can check beforehand if the scanner is connected or disconnected by sending an Intent to com.proglove.api.GET_SCANNER_STATE
.
This can result in three different status callbacks to com.proglove.api.SCANNER_STATE
:
Disconnected
Connected
No response
Note
No response means that either the service is not running/started, or the app is not installed. In the case of no response you can still use startActivity
(PairingActivity) (in which case the user has to pair again).
For special cases, you can modify the default pairing behavior using the following Extras:
Extra key | Value type | Description | Default value |
---|---|---|---|
| Boolean | Allows the Android device to re-initiate the Pairing process. | true |
| String | User-defined advertising name. | 10 random characters (max length) |
| Long | If no activities are recorded during this timeframe after pairing your ProGlove scanners, the connection will time out automatically. | 60000 (milliseconds) |
| Boolean | The possibility to suppress the requirements info dialog shown before permission system dialogs. (requires INSIGHT Mobile (Android) 1.31.0) | false |
Note
The default value of time_out_in_ms_extra
should not be changed to maintain stability in pairing process.