Back to top

Use intent output

Last updated July 26th, 2023

If your business app needs to obtain scanned data programmatically (for example, to process it further in-app), Knox Capture can pass the data within an Android intent object instead of through keystroke output.

You can also enable intent output to work with keystroke output. For example, if you select Send via startActivity as your intent delivery method, Knox Capture first sends keystrokes to the foreground activity, then sends the intent to the new activity instance.

To use Knox Capture’s intent output feature:

  • Business app developers must ensure the business app receives the intent, and
  • IT admins must configure Knox Capture’s Intent output feature accordingly.

The information in this section is divided into instructions for business app developers and instructions for Knox Capture admins.

For business app developers

Edit the AndroidManifest.xml file

For your business app to parse the scanned data, you need to set up Knox Capture to send it the correct intent output. To do so, edit AndroidManifest.xml to define the package name, intent action and category. Knox Capture offers three different methods for your app to receive an Android intent. Refer to Intent output settings for more details.

The following is a snippet demonstrating the manifest information to edit. Ensure you replace any dummy strings with ones relevant to your app.

PackageName =
applicationId "com.test.smartscan"

AndroidManifest.xml

If you’re using an activity to receive the intent:

<activity android:name=".IntentOutputActivity">
    <intent-filter>
        <action android:name="testintent.action.activity"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

If you’re using the foreground service to receive the intent:

<service android:name=".ForegroundService">
    <intent-filter>
        <action android:name="testintent.action.service"/>
    <intent-filter>
</service>

If you’re using the broadcast receiver to receive the intent:

<receiver android:name=".DummyReceiver">
    <intent-filter>
        <action android:name="test.intent.action.receiver"/>
    </intent-filter>
</receiver>

Properly defining the intent filter information ensures that after each successful scan, Knox Capture delivers the intent to your business app through the chosen method.

What’s included in the intent output

After a successful scan, the configured intent triggers and is sent to the business app along with the following key information.

Test mode status

If Send via startActivity is selected as the intent delivery, test mode can be affected. If test mode is active, the intent is not sent and the business app is not launched. Instead, the following error message appears, notifying you that test mode is active: Not Start Activity in TestMode!

The key/value pair that signifies test mode status is as follows:

Key:= ProfileConstants.KEY_INTENT_TEST_MODE="intent_in_testmode"
Value:= true/false : whether Knox Capture test mode is on.

The list of scanned bundles

The key/value pair that contains the scanned barcode data is as follows:

Key:= ProfileConstants.INTENT_OUTPUT_SCANNED_BUNDLE_LIST= "com.samsung.smartscan.scanned_bundle_list"
Value:= bundle list : the scanned barcode data
const val INTENT_OUTPUT_UNPROCESSED_RAW_DATA = "com.samsung.smartscan.unprocessed_raw_data"
const val INTENT_OUTPUT_UNPROCESSED_STRING_DATA = "com.samsung.smartscan.unprocessed_string_data"
const val INTENT_OUTPUT_SYMBLOGY_TYPE = "com.samsung.smartscan.symblogy_type"
const val INTENT_OUTPUT_SCAN_SOURCE = "com.samsung.smartscan.scan_source"
const val INTENT_OUTPUT_SCANNER_TYPE = "com.samsung.smartscan.scanner_type"

The bundle structure

{
    "com.samsung.smartscan.scanner_type": scanner type
    "com.samsung.smartscan.scan_source": Scandit
    "com.samsung.smartscan.symblogy_type": barcode symbology, like EAN13
    "com.samsung.smartscan.unprocessed_string_data": scanned string data
    "com.samsung.smartscan.unprocessed_raw_data": scanned data in bytes
}

const val KEY_SCANNER_TYPE_CAMERA = "camera"

Reading the intent output information

The following code snippet, written in Kotlin, demonstrates how to get and read the data sent from Knox Capture.

fun getAllExtraInfo(intent: Intent):String{
    val sb = StringBuilder()
    val list: ArrayList? = intent.getParcelableArrayListExtra(INTENT_OUTPUT_SCANNED_BUNDLE_LIST)

    list?.let {
        sb.append("bundleList::{")
        for(bundleItem in list){
            sb.append("[")
            bundleItem.getString(INTENT_OUTPUT_SCANNER_TYPE)?.let {
                sb.append(" scanType= $it, \n")
            }
            bundleItem.getString(INTENT_OUTPUT_SCAN_SOURCE)?.let {
                sb.append(" scanEngine= $it, \n")
            }
            bundleItem.getString(INTENT_OUTPUT_SYMBLOGY_TYPE)?.let {
                sb.append(" symbology= $it, \n")
            }
            bundleItem.getStringArrayList(INTENT_OUTPUT_UNPROCESSED_STRING_DATA)?.let {
                sb.append(" strData= ${it.joinToString {"$it " }}, \n")
            }
            bundleItem.getByteArray(INTENT_OUTPUT_UNPROCESSED_RAW_DATA)?.let {
                sb.append("rawData= ${toHex(it,true)}")
            }
            sb.append("]")
        }
        sb.append("}")
    }
    return sb.toString()
}

Knox Capture configuration

You must instruct the IT admin to configure the same package and intent delivery method as specified in the AndroidManifest.xml file. The following example demonstrates how the IT admin should configure Knox Capture if the intent is received when starting a new activity.

  • Intent actionintent.action.activity
  • Intent categoryintent.category.DEFAULT
  • Intent deliverySend via startActivity
  • Component informationtest.smartscan

For Knox Capture admins

To set up intent output:

  1. On the Knox Capture home screen, tap on the profile you want to set intent output for.

  2. Under Intent output, tap Select app packages.

  3. Select the apps for intent output, then tap < in the top left to return to the previous screen. Make sure the package name matches your business app.

  4. Under Intent output, specify an Intent action, Intent category, and Intent delivery method to handle the intent.

    • Intent action and category — The intent filter information matching the business app’s intent filter information. For example, if IntentOutputActivity is receiving the intent, Knox Capture needs to configure the action as intent.action.activity and the category as android.intent.category.DEFAULT.
    • Intent delivery — The app activity that handles the intent-based data. Refer to Intent output settings for descriptions of each activity.

    For more details on how to find the intent filter information, see Edit the AndroidManifest.xml file.

At any time, change the apps designated for intent output by tapping Manage app packages under Intent output.

Intent output settings

Refer to the following settings to configure an Android intent:

The intent action and category must match the ones defined in your business app’s AndroidManifest.xml file, under a component’s intent-filter element. For detailed instructions, contact the developers of the app.

  • Application package name — Selects one or more apps to receive the intent.
  • Intent action — Designates an action to handle the intent.
  • Intent category — Sets the category of the intent action.
  • Intent delivery — Selects one of three delivery methods for intent-based data:
    1. Send via startActivity — Launches the activity to pass data through.
    2. Send via startForeground — Creates a foreground service from an activity or app component to pass data through. This option is only available for devices running Android 8 and above.
    3. Broadcast Intent — Gives the business app’s broadcast receiver foreground priority on the device to speed up data delivery. Use this delivery method only if you’re experiencing delays when sending scanned data immediately after the device is booted.

After you configure an Android intent, the intent delivery method is added to the blue test overlay in Test mode. Refer to Use test mode for steps on how to check your configuration.

Is this page helpful?