Intent API - Basic Integration

The ProGlove Connect app sends out certain things via Broadcast Intents, and listens for certain Broadcast Intents in response. These can originate from any app on this device, including Cordova/React applications.
Important: MARK has to be paired using the ProGlove Connect App before this API will work!
For an introduction to Intents on Android please refer to the official documentation:

Receiving Barcode Data

  1. In the INTEGRATION PATHS menu please select the option Intent and press NEXT.

SCREENSHOT OF WIZARD

  1. Define the INTENT ACTION.
    • Default: com.proglove.api.BARCODE
    • Extras:
      • String in com.proglove.api.extra.BARCODE_DATA contains the Barcode Data.
        • For easier integration, we also supply the barcode data in the extra com.symbol.datawedge.data_string.
      • String in com.proglove.api.extra.BARCODE_SYMBOLOGY contains the barcode's Symbology, e.g. "EAN-13" (see Symbologies for the full list of supported Symbologies).
        • For easier integration, we also supply the symbology data in the extra com.symbol.datawedge.label_type.
  2. Select DONE.

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.BARCODE") {
            intent.getStringExtra("com.proglove.api.extra.BARCODE_DATA")
            intent.getStringExtra("com.proglove.api.extra.BARCODE_SYMBOLOGY")
        }
    }
}
  1. Define an IntentFilter filtering for the specified actions:
val messageHandler: MessageHandler = MessageHandler()
val filter = IntentFilter()
filter.addAction("com.proglove.api.BARCODE")
filter.addCategory(Intent.CATEGORY_DEFAULT)
  1. Finally register the broadcast receiver instance with a context. The usual place for this call would be in the onCreate method of a Service or an Activity class:
context.registerReceiver(messageHandler, filter)

Do not forget to unregister the receiver again, for example in onDestroy:

context.unregisterReceiver(messageHandler)

Logging/Output

Unless otherwise specified, the API Calls have no return value. In these cases, the results will be logged to the Android console and can be viewed by filtering logcat to de.proglove.connect.intent.api or PGAPI

adb logcat -e PGAPI

Getting Connection State

Once the pairing process is started, the ProGlove Connect App will send out the current connection State of the MARK.

  • Action: com.proglove.api.SCANNER_STATE
  • Extra: String in com.proglove.api.extra.SCANNER_STATE

Example code to get scanner state events:

  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.SCANNER_STATE") {  
            intent.getStringExtra("com.proglove.api.extra.SCANNER_STATE")  
        }  
    }  
}
  1. Define an IntentFilter for the desired actions:
val messageHandler: MessageHandler = MessageHandler()  
val filter = IntentFilter()  
filter.addAction("com.proglove.api.SCANNER_STATE")  
filter.addCategory(Intent.CATEGORY_DEFAULT)
  1. Register the broadcast receiver instance with a context. The usual place for this call would be in the onCreate method of a Service or an Activity class:
context.registerReceiver(messageHandler, filter)
  1. Do not forget to unregister the receiver again, for example in onDestroy:
context.unregisterReceiver(messageHandler)


The passed Status String can be one of:

  • "CONNECTED": MARK is connected, the user can start scanning.
  • "DISCONNECTED": No MARK is connected.
  • "CONNECTING": In the process of establishing a MARK BLE Connection.
  • "ERROR": Something went wrong trying to establish the MARK Connection or the BLE Search in general. Consult the ProGlove Connect App.
  • "RECONNECTING": Lost connection to a previously connected MARK, trying to re-establish the connection.
  • "SEARCHING": Searching for a MARK and showing the PAIRING Screen (including the QR code).

The examples above can be unified to one class handling all events by adding the other Action to the IntentFilter object. Then onReceive gets called for both kinds of events.

Connecting MARK

To start the MARK Pairing Process and show the QR Activity, send a Broadcast Intent to:

  • Action: com.proglove.api.CONNECT
  • No Extras

Example code:

val intent = Intent()  
intent.setAction("com.proglove.api.CONNECT")  
sendBroadcast(intent)

PLEASE NOTE: On Android 8 or higher, this might fail because the ProGlove Connect App is not running in the background. Please start the Pairing Process using the ProGlove Connect Work App.

Disconnecting MARK

To disconnect a connected MARK, send a Broadcast Intent to:

  • Action: com.proglove.api.DISCONNECT
  • No Extras

Example code:

val intent = Intent()  
intent.setAction("com.proglove.api.DISCONNECT")  
sendBroadcast(intent)

Querying MARK State

To query the connection state of MARK, send a Broadcast Intent to:

  • Action: com.proglove.api.GET_SCANNER_STATE
  • No Extras

This will trigger the com.proglove.api.SCANNER_STATE Broadcast from the ProGlove Connect App as explained in the section above.

Example code:

val intent = Intent()  
intent.setAction("com.proglove.api.GET_SCANNER_STATE")  
sendBroadcast(intent)

PLEASE NOTE: On Android 8 or higher, this might fail because the ProGlove App is not running in the Background. Please start the pairing process using the ProGlove Worker App

Start Pairing Barcode From Within Your Business Application

Here is a code snippet with which you can invoke the so called 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)  

Please note that on starting the PairingActivity the MARK scanner will be disconnected (which means the user has to pair again). However, you could check beforehand if MARK is connected or disconnected by sending an Intent to com.proglove.api.GET_SCANNER_STATE.

Please note that this would result in 3 different status callbacks to com.proglove.api.SCANNER_STATE: -Disconnected -Connnected -No response.

“No response” means that either the service is not running/started, or the app is not installed. In the case of no response you could still startActivity(PairingActivity), and it would still work (in this case the user has to pair again).

Start Your Business Application Automatically With Action

To start your business application automatically with action, we will send an Intent of the following structure:

  • Action: com.proglove.api.BARCODE_START_ACTIVITY
  • No Extras

During setup check the box next to Start Activity before clicking DONE. By doing so a default startActivity rule will be created, which is pre-defined to start your business app with an action by an oncoming barcode event.
Example code:

<intent-filter>  
<action android:name="com.proglove.api.BARCODE_START_ACTIVITY"/>  
<category android:name="android.intent.category.DEFAULT"/>  
</intent-filter>

This snippet needs to be added into your business application's xml file under activity. The action name can be modified to your liking, but the category name must be left as android.intent.category.DEFAULT.
For our customers who plan to use the PG Work Icon to pair their devices, we recommend modifying this rule to automatically start your application after the MARK device is connected to your Android device. For this, go to Workflow Rules in the PG Config Icon and click on the rule Start Activity. Under the Conditions section, change the Event Type from Incoming barcode event to Paired scanner event. From now on, your business application will start automatically when your MARK connects to your Android device.

Start Your Business Application Automatically With Component

To use startActivity with component to start any app that shall recieve the barcode automatically you need to know:

  • Target App Package
  • Target App Activity

To find out the two needed parameters above, we recommend using an app called "Current Activity" that can be installed from Play Store. After the app has been downloaded, enable Show floating window and a small window made up of two lines of text will appear on the top left side of your device. The first line defines the currently open app's Target App Package, while the second is the Target App Activity. Open your business app and note down these parameters.

Then go to Workflow Rules in the Main Menu and click on the rule Send with Intent. Under the Actions section, change the Type to Send via startActivity() with component. Under Target App Package write the name of your application's package and under Target App Activity write the name of your app's activity name. For the condition we recommend using On event - Paired scanner event as this allows the selected app to open automatically when a MARK scanner is paired with your device.

Symbologies

See Symbologies for the list of supported symbologies.

Please note that Current Activity is not a product of ProGlove. This platform may include links or references to these and other third party products, software, services or websites. These are not under the control of ProGlove and ProGlove is not responsible for them. ProGlove is providing these links or references only as a convenience, and the inclusion does not imply endorsement by ProGlove. Your use of the third party products, software, services or websites may be subject to that third party's terms and conditions.