SDK API - Button
PLEASE NOTE: THE USAGE OF THIS FEATURE IS RESTRICTED AND ONLY AVAILABLE AS BETA THROUGH OUR EARLY ACCESS PROGRAM. PLEASE FILL OUT THE REGISTRATION FORM TO APPLY.
The ProGlove Button SDK API enables you to receive events beyond simple barcode retrieval. At the moment the feature allows you to receive an event in your application when the trigger is pressed twice in quick succession, like a double click on a computer mouse.
Receiving Button Events
The ProGlove Connect app will send out a button press event for any physical button press an a connected Device.
Additionally it will also send out a button press if the MARK trigger is pressed twice in quick succession, like a double click on a computer mouse.
To get this, call the pgManager.subscribeToButtonPresses()
function and implement the IButtonOutput
interface.
For example, in the same onCreate
of our sample app we subscribe to the display info.
And we unsubscribe in the onDestroy
function.
override fun onCreate(savedInstanceState: Bundle?) {
//...
pgManager.subscribeToButtonPresses(this)
//...
}
override fun onDestroy() {
super.onDestroy()
pgManager.unsubscribeFromButtonPresses(this)
}
To do this, our Activity needs to implement the IButtonOutput
interface:
``` // // -- IButtonOutput -- //
override fun onButtonPressed(buttonPressed: ButtonPress) { // the button presses will come on background threads, make sure to execute this on the UI Thread runOnUiThread { Toast.makeText(this, "Got a button Press: ${buttonPressed.id}", Toast.LENGTH_SHORT).show() } }