<activity android:name="com.demo.app.features.MyDemoActivity" android:exported="true" android:launchMode="singleTop"> <intent-filter> <action android:name="com.demo.app.myActionName.ACTION" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) intent.getStringExtra(DataWedgeHelper.DATA_KEY)?.let { // Use the scanned QR code } }
object DataWedgeHelper { const val DATA_KEY = "com.symbol.datawedge.data_string" const val API_ACTION = "com.symbol.datawedge.api.ACTION" const val API_SCAN_TRIGGER = "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER" const val START_SCANNING = "START_SCANNING" const val STOP_SCANNING = "STOP_SCANNING" }
binding.scanItemsButton.setOnTouchListener { _, motionEvent -> if (motionEvent?.action == MotionEvent.ACTION_DOWN) { Intent().apply { action = DataWedgeHelper.API_ACTION putExtra(DataWedgeHelper.API_SCAN_TRIGGER, DataWedgeHelper.START_SCANNING) sendBroadcast(this) } } else if (motionEvent?.action == MotionEvent.ACTION_UP) { Intent().apply { action = DataWedgeHelper.API_ACTION putExtra(DataWedgeHelper.API_SCAN_TRIGGER, DataWedgeHelper.STOP_SCANNING) sendBroadcast(this) } } true }