Intent 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 Intent 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 the following Intent if the trigger is pressed twice in quick succession. The same Intent structure will be sent out for other physical button presses on the device.
- Action: com.proglove.api.DISPLAY_BUTTON
- Extras:
- String in com.proglove.api.extra.DISPLAY_BUTTON contains the id of the pressed button
In order to receive broadcast intents the following steps are needed (code is in Kotlin):
1 Implement a broadcast receiver (in this case the class is called MessageHandler):
class MessageHandler : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent != null && intent.action == "com.proglove.api.DISPLAY_BUTTON") {
intent.getStringExtra("com.proglove.api.extra.DISPLAY_BUTTON")
}
}
}
2 define an IntentFilter filtering for the specified actions:
val messageHandler: MessageHandler = MessageHandler()
val filter = IntentFilter()
filter.addAction("com.proglove.api.DISPLAY_BUTTON")
filter.addCategory(Intent.CATEGORY_DEFAULT)
3 Somewhere where a context is available (usually an Activity's or Service's onCreate):
context.registerReceiver(messageHandler, filter)
Do not forget to unregister the receiver again, for example in onDestroy:
context.unregisterReceiver(messageHandler)