Back to top

Start scan from business app

Last updated October 10th, 2024

You can configure Knox Capture to allow end users to trigger a barcode scan by tapping a “soft-trigger” button from within a business app’s UI, instead of using the floating action button, or relying on a separate hardware key.

Admin workflow

Prerequisites

Before you can configure Knox Capture to launch from a business app, you must first ensure that your business app developers have implemented the correct trigger logic in their code. Refer them to the Knox Capture soft-trigger developer tutorial, as well as the corresponding sample code on how to do this.

Configure Knox Capture

Once your developers have implemented a soft-trigger in the app, you’ll need to configure the following in Knox Capture:

  1. On your app’s home screen, tap Options > Camera scan triggers.

    KCAP start scan from Business App open option

  2. On the Camera scan triggers screen, go to the Receive intent from third-party app section, then tap Start scan from business app.

  3. On the following screen, turn the feature On, then return to the app home screen.

  4. Tap the scanning profile that you want to use for your end users. If you didn’t create any custom profiles, tap Default scanning profile.

    KCAP start scan from Business App enable toggle

  5. On the profile screen, scroll to the bottom, then under Intent output, tap Select app packages.

  6. Select the app that you want use to trigger a scan, then return to the profile screen.

    KCAP start scan from Business App select app packages

  7. On the profile screen, you’ll see the selected app under Intent output. Configure the following:

    • Under Action, enter the intent action that you want to trigger the barcode scanner. This information must be obtained from your app developer.
    • Under Category, leave this blank.
    • Under Delivery, select Broadcast intent.

    KCAP start scan from Business App configure intent output

  8. Once the app is configured, return to the app’s home screen and export the profile’s configuration file to your EMM.

  9. In your EMM, create a managed configuration for Knox Capture and deploy the saved configuration to your end user’s devices.

Developer workflow

This content is intended for 3rd party app developer audiences who need to implement a Knox Capture soft-trigger button in their customer’s business app’s UI.

About soft-triggers

A soft-trigger in your app’s UI allows customers to initiate a scan using a dedicated UI button instead of Knox Capture’s floating action button, or a specific hardware key. The following sample code — written in Kotlin — can be used as a template when configuring your app.

Define scan trigger options in the app UI

Before you configure your customer’s business app to soft-trigger Knox Capture, you should confirm with your customer the scan modes and barcode selection methods they want to use. See the Scan engine settings documentation for an explanation of each scan mode and the barcode selection methods available.

Use the following sample code to define the scan modes and selection types available to your customers when using the app.

val scanModeCandidates = listOf( "Single scan","Multi scan", )
val scanSelectionCandidates = listOf("Automatic","Batch","Aim and scan", "Tap to select")

The following sample code triggers a single scan using automatic barcode selection, based on the values defined above:

private var scanMode = scanModeCandidates[0]
private var selection = scanSelectionCandidates[0]

Create the soft-trigger intent

val i = Intent().also {
    it.action="com.samsung.android.knox.intent.api.ACTION"
    it.putExtra("com.samsung.android.knox.intent.api.TRIGGER_ACTION","START")
    it.setPackage("com.samsung.android.app.smartscan")
    /**this will tell what kind of scan you are going to trigger 
    based on the previous code scanMode = "Single scan" and selection = "Automatic"**/
    it.putExtra("scanner_mode",scanMode)
    it.putExtra("barcode_selection",selection)
    val p = PendingIntent.getActivity(
        this,
        0,
        /**Enter your business app's intent. Provide this intent to the customer**/
        Intent(), 
        /** Set both of these flags **/ 
        PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT 
     )
    it.putExtra("pending_intent",p)
}
sendBroadcast(i)

Troubleshooting

After you configure the business app, you can use Knox Capture to test your soft-trigger button. If you attempt to trigger a scan using the soft-trigger, but Knox Capture doesn’t launch, consider trying the following:

  • Is the Start scan from business app feature enabled?
  • If you’re using a custom profile, is the activity in that profile?
  • Is your activity running in the foreground when you broadcast the intent? Knox Capture only allows foreground apps to trigger a scan.
  • Is the pendingIntent object added to your broadcast? Knox Capture will need it to verify the sender for security purposes.
  • Is Knox Capture active? If you installed Knox Capture but never launched the app, it remains in an inactive state and will not listen to broadcasts from any 3rd party app. Launch Knox Capture to activate it.

End user workflow

After you deploy Knox Capture to your devices, the device users simply launch the scanner by opening their business app and tapping the soft-trigger button on the UI.

KCAP start scan from Business App end user workflow

Is this page helpful?