Intent not being sent

// Expert user has replied.
D Dave Hon 1 year 4 months ago
295 4 0

I'm trying to send barcode data using dataWedge on a WS50. I'm working on an app in Kotlin.

My receiver is registered, but the intent isn't being delivered. The logCat I placed in the receiver have never been triggered, even after I scan a barcode. Below are some code snippets and screenshots of my profile. The profile is loading because I am able to change device settings (screen brightness, for example.)

 

Barcode Receiver

class BarcodeReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        Log.d("BarcodeReceiver", "onReceive triggered")
        val action = intent.action
        if (action != null && action == "com.example.zonepick.SCAN") {
            val extras = intent.extras
            if (extras != null && extras.containsKey("com.symbol.datawedge.data_string")) {
                val barcodeData = extras.getString("com.symbol.datawedge.data_string")
                Log.d("BarcodeReceiver", barcodeData.toString())
            }
        }
    }
}

Android Manifest
 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <queries>
        <package android:name="com.symbol.emdk.emdkservice" />
    </queries>
    <uses-permission android:name="com.symbol.emdk.permission.EMDK" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" tools:targetApi="s" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:ignore="CoarseFineLocation" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-feature android:name="android.hardware.type.watch"/>
    <application
        android:launchMode="singleTop"
        android:name=".ZonePickApplication"
        android:usesCleartextTraffic="true"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.ZonePick"
        tools:targetApi="31">
        <uses-library android:name="com.symbol.emdk"/>
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.ZonePick"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver
            android:name=".BarcodeReceiver"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.example.zonepick.SCAN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

    </application>

</manifest>

Registering the receiver (This is in a composable loaded in the MainActivity
 

    DisposableEffect(Unit) {

        val barcodeReceiver = BarcodeReceiver()

        val intentFilter = IntentFilter("com.example.zonepick.SCAN")
        Log.d("Home", "Registering receiver")
        context.registerReceiver(barcodeReceiver, intentFilter)

        onDispose {
            context.unregisterReceiver(barcodeReceiver)
            Log.d("Home", "Unregistering receiver")
        }
    }

The Profile:
Profile1ProfileActBarcodeIntent

Please Register or Login to post a reply

4 Replies

K Kyle Falconer

I'm having the same issue with trying to get the WS50 to output barcode data. The same application and broadcast receiver is working on the TC52, but not the WS50. The scan button works, and I have a camera preview showing up, which beeps when a barcode is seen, but no data is ever sent.

Dave, what application are you using to view the profile in those last 4 screenshots? I've been trying to verify that my profile is correct, but the WS50 doesn't allow me to see the profile details within the DataWedge app, and the StageNow application on Windows doesn't  seem to be able to open the exported datawedge.db file (it's only able to open .zip and .xml).

 

When I create the profile, I get "SUCCESS", so I assume everything is fine.

 Command:      com.symbol.datawedge.api.SET_CONFIG
 Result:       SUCCESS
 Result Info:  PROFILE_NAME: ProfileDemo
 CID:          SET_INTENT_OUTPUT

 

This is how I'm building my profile Bundle:

class DataWedgeProfileBuilder @Inject constructor(
    @ActivityContext context: Context,
    private val signatureProvider: SignatureProvider
){
    
    private val profileIntentAction = context.resources.getString(R.string.activity_intent_filter_action)

    fun buildProfileBundle() : Bundle {

        val profileBundle = createProfile()

        val bundlePluginConfig = mutableListOf<Bundle>()
        bundlePluginConfig.add(configureScannerPlugin())
        bundlePluginConfig.add(configureIntentPlugin())


        profileBundle.putParcelableArray("PLUGIN_CONFIG", bundlePluginConfig.toTypedArray())
        return profileBundle
    }

    private fun createProfile(profileName:String = "ProfileDemo") : Bundle {
        val bMain = Bundle()
        bMain.putString("PROFILE_NAME", profileName)
        bMain.putString("PROFILE_ENABLED", "true")
        bMain.putString("CONFIG_MODE", "CREATE_IF_NOT_EXIST")
        return bMain
    }

    private fun configureScannerPlugin() :Bundle {
        val barcodePluginBundle = Bundle()
        barcodePluginBundle.putString("PLUGIN_NAME", "BARCODE")
        barcodePluginBundle.putString("RESET_CONFIG", "true")

        val barcodeParamsBundle = Bundle()
        barcodeParamsBundle.putString("decoder_code39", "true")
        barcodeParamsBundle.putString("decoder_upca", "true")
        barcodeParamsBundle.putString("scanner_selection", "auto")
        barcodeParamsBundle.putString("scanner_input_enabled", "true")
        barcodeParamsBundle.putStringArray("scanner_trigger_resource", arrayOf("LEFT", "RIGHT"))
        barcodeParamsBundle.putString("picklist", "1");
        barcodePluginBundle.putParcelableArrayList("PARAM_LIST", arrayListOf(barcodeParamsBundle))
        return barcodePluginBundle
    }


    private fun configureIntentPlugin() : Bundle {
        val bConfigIntent = Bundle()
        bConfigIntent.putString("PLUGIN_NAME", "INTENT")
        bConfigIntent.putString("RESET_CONFIG", "true")

        val intentParams = Bundle()
        intentParams.putString("intent_output_enabled", "true")
        intentParams.putString("intent_action", profileIntentAction)
        intentParams.putString("intent_category", "android.intent.category.DEFAULT")
        intentParams.putInt("intent_delivery", 2)

        val component0 = Bundle()
        signatureProvider.getSignatures().firstOrNull()?.let { sig ->
            component0.putString("PACKAGE_NAME", sig.packageName)
            component0.putStringArray("ACTIVITY_LIST", listOf("*").toTypedArray());
            component0.putString("SIGNATURE", sig.sigSha1)
        }
        intentParams.putParcelableArray("intent_component_info", listOf(component0).toTypedArray())
        bConfigIntent.putBundle("PARAM_LIST", intentParams)

        return bConfigIntent
    }
}

 

And I'm creating the Intent in another class:

        val bMain = profileBuilder.buildProfileBundle()

        val iSetConfig = Intent()
        iSetConfig.action = "com.symbol.datawedge.api.ACTION"
        iSetConfig.putExtra("com.symbol.datawedge.api.SET_CONFIG", bMain)
        iSetConfig.putExtra("SEND_RESULT", "LAST_RESULT")
        iSetConfig.putExtra("COMMAND_IDENTIFIER", "SET_INTENT_OUTPUT")

 

S Sean Kennedy

A Quick Question:

Have you referred to the TechDoc Datawedge article regarding the WS50?

https://techdocs.zebra.com/datawedge/13-0/guide/programmers-guides/ws50/

There is also a Demo that goes with that for the WS50 (Truck Loading Demo) here:

https://techdocs.zebra.com/ws50/guide/demo/truck-loading/

I would expect that with the cut down version of Android that the WS50 operates with - that EMDK may not function as expected.
( EDMK has been suggested to developers to migrate to Datawedge.)

K Kyle Falconer

Thanks for the response Sean. The truck loading demo does work for me on the WS50, but the code provided does not include the profile creation step.

How can I compare my configuration with dwprofile_truckloadingdemo.db or validate that my configuration is setting the required values correctly? I noticed that I can open dwprofile_truckloadingdemo.db in an SQLite viewer, but that's really cumbersome.

S Sean Kennedy

Hi Kyle.

As much as SQLite viewer allows you to see the data, Try to use Datawedge to view the config instead if you have a Zebra Android device (Like a TC52 or an MC33.)

You can import the "truckloading_demo" profile onto these platforms and use Datawedge to look at the config.

Similarly - when you make a change to your profile "programmatically" - you can check on this with Datawedge.

*(A good example of this is using DataCapture1 on a Zebra Android Device - uncheck all 4 barcode decoders, set the setting, and quit the app, go into Datawedge app, and open the "DWDatacapture1" profile and look at the scanner settings - and the "Decoders" menu and see the 4 types that are now disabled. )*

CONTACT
Can’t find what you’re looking for?