Skip to main content

Intent Integration

Introduction

This section outlines the capabilities of our Intent, which facilitates seamless integration with the Android Aladdin application. The Intent provides a sophisticated registering model, enabling developers to efficiently receive and manage scanned data. With built-in functionalities for sharing data, developers gain a professional and adaptable solution for incorporating scanned data into their applications.

Intent Integration in Aladdin

  1. Select Intent option in the Integration UI of Aladdin application.

  2. A UI will appear to enter name for barcode action, barcode data, label type and scan time extra name in respective input fields.

  3. The input fields will be pre-populated with default names, but you can change these names.

    Intent

    Below are the default values used in Aladdin app for barcode action, barcode data, label type and scan time extra name.

    • Barcode event action name: com.datalogic.aladdinapp.intent.ACTION_SEND_BAR_CODE_DATA
    • Barcode data extra name: com.datalogic.aladdinapp. extra.BARCODE_DATA
    • Barcode label type extra name: com.datalogic.aladdinapp.extra.BARCODE_CODE_TYPE
    • Barcode scan time extra name: com.datalogic.aladdinapp.extra.BARCODE_SCAN_TIME
  4. If you have selected Intent as integration method, whenever the HHS scans a barcode, the application will send a broadcast with barcode event action name, barcode data extra name, barcode label type extra name and barcode scan time extra name which you entered in step 3.

  5. In Aladdin application, the “com.datalogic.aladdinapp.intent” value is fixed. You will only enter the name and extra names.

Client Application Implementation

1. Barcode event

To receive a barcode event in the client application, the client must implement a broadcast receiver with the action and extras name that you entered in the Aladdin application.

Example:

class BarCodeReceiver : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {

if ("com.datalogic.aladdinapp.intent.ACTION_SEND_BAR_CODE_DATA" == intent.action) {

val data = intent.getStringExtra("com.datalogic.aladdinapp.extra.BARCODE_DATA")

val codeType = intent.getStringExtra("com.datalogic.aladdinapp.extra.BARCODE_CODE_TYPE")

val scanTime = intent.getStringExtra("com.datalogic.aladdinapp.extra.BARCODE_SCAN_TIME")

Toast.makeText(context, data, Toast.LENGTH_SHORT).show()
}
}
}

Define an IntentFilter for the specified actions:

val barCodeReceiver = BarCodeReceiver()

val barCodeIntent = IntentFilter("com.datalogic.aladdinapp.intent.ACTION_SEND_BAR_CODE_DATA")

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:

registerReceiver(barCodeReceiver, barCodeIntent)

2. Connection status event

You can get scanner connection state by registering to below action name com.datalogic.aladdinapp.intent.ACTION_SEND_SCANNER_STATE and extras name as com.datalogic.aladdinapp.extra.SCANNER_STATE

Implement a broadcast receiver.

class ScannerStateReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if ("com.datalogic.aladdinapp.intent.ACTION_SEND_SCANNER_STATE" == intent.action) {
val data =
intent.getBooleanExtra("com.datalogic.aladdinapp.extra.SCANNER_STATE", false)
if (data) {
Toast.makeText(context, "Connected to scanner", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(context, "Disconnected from scanner", Toast.LENGTH_SHORT).show()
}
}
}
}

Define an IntentFilter for the specified actions:

val scanStateReceiver = ScannerStateReceiver()
val connectionStateIntent =
IntentFilter("com.datalogic.aladdinapp.intent.ACTION_SEND_SCANNER_STATE")

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:

registerReceiver(scanStateReceiver, connectionStateIntent)

3. Get Last Scan Data

You can get the last scanned data by sending the below broadcast. The Aladdin application will send the latest bar code details in following action: “com.datalogic.aladdinapp.intent.ACTION_SEND_BAR_CODE_DATA

val intent = Intent("com.datalogic.aladdinapp.intent.ACTION_GET_LATEST_SCAN_DATA")
sendBroadcast(intent)

4. Get Connection State

You can get the scanner connection state by sending the below broadcast. The Aladdin application will send the connection details in the following action: “com.datalogic.aladdinapp.intent.ACTION_SEND_SCANNER_STATE

val intent = Intent("com.datalogic.aladdinapp.intent.ACTION_GET_SCANNER_STATE")
sendBroadcast(intent)

Validating the Integration

  1. Select Intent as integration method in the Aladdin app.

  2. The Intent setting UI will appear with some pre-populated data. You can change the content of each input text field and tap the Save button to confirm. Please, note that each field should contain unique data and the same data should not be repeated.

  3. Open the Intent client application.

  4. Tap the "Register to Aladdin" button.

  5. A pop-up will appear with 4 input pre-populated text fields. The name of each field must be the same you entered in step 2.

    Intent_test_1

    Intent_test_2

    Intent_test_3

  6. You can now scan any barcode/QR code with your HHS device. The barcode details will be displayed in a toast message in the client application.

    Intent_test_4

  7. You can also tap "Get latest bar code" and retrieve the last barcode data.

  8. To check the scanner status, tap "Get Scanner Status".

    Intent_test_5

  9. To unregister from the Aladdin application, tap "Unregister from Aladdin".

    Intent_test_6

Notes:

  • The client could register to Aladdin irrespective of any integration method selected in the application, but it cannot receive barcode data or connection state if Intent is not selected as integration method in Aladdin.
  • If Intent is selected as integration method, but the barcode action name, barcode data, label type, scan time and extra names entered in the Aladdin app and in the intent client app are not the same, you will not be able to receive barcode events in the client app. You can only get the scanner status. You can unregister from Aladdin and then register anew with the same key values entered in the Aladdin app.
  • If Intent is not selected as integration method in the Aladdin app and you try to register to the Intent client application, registration will be successful but the "Get latest bar code" and the "Get Scanner Status" buttons will be disabled and you will not be able to receive new barcode data scanned by HHS.
  • To ensure that you get proper barcode events in the client app, the key name for "barcode action", "barcode data extra name", "label type extra" and "scan time extra name" should be same in both Aladdin and Intent client app.
  • User input for barcode extra names (barcode data extra name, label type extra name and scan time extra name) should be unique.
  • If all data are equal and unique in both client and Aladdin app, you will get the barcode details in the toast message.
  • If the names of the barcode actions are not equal and the extra names are not matching in both Aladdin application and Intent client app, you will not receive the toast message.
  • If the names of the actions are equal and the extra names are not matching in both Aladdin application and Intent client application, you will not receive the barcode data in the toast message. According to the toast message, you need to change the input data and try again.