### Triggering Soft Scan via DataWedge API Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md These snippets demonstrate how to send an Intent to the DataWedge service to start or stop scanning based on touch events. ```java public boolean onTouch(View view, MotionEvent motionEvent) { if (view.getId() == R.id.btnScan) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { // Button pressed, start scan Intent dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); sendBroadcast(dwIntent); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { // Button released, end scan Intent dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING"); sendBroadcast(dwIntent); }} } ``` ```kotlin override fun onTouch(view: View?, motionEvent: MotionEvent?): Boolean { if (view?.getId() == R.id.btnScan) { if (motionEvent?.getAction() == MotionEvent.ACTION_DOWN) { // Button pressed, start scan val dwIntent = Intent() dwIntent.action = "com.symbol.datawedge.api.ACTION" dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING") sendBroadcast(dwIntent) } else if (motionEvent?.getAction() == MotionEvent.ACTION_UP) { // Button released, end scan val dwIntent = Intent() dwIntent.action = "com.symbol.datawedge.api.ACTION" dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING") sendBroadcast(dwIntent) }} } ``` ```csharp btnScan.Touch += (s, e) => { if (e.Event.Action == MotionEventActions.Down) { // Button pressed, start scan Intent dwIntent = new Intent(); dwIntent.SetAction("com.symbol.datawedge.api.ACTION"); dwIntent.PutExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); SendBroadcast(dwIntent); } else if (e.Event.Action == MotionEventActions.Up) { // Button released, end scan Intent dwIntent = new Intent(); dwIntent.SetAction("com.symbol.datawedge.api.ACTION"); dwIntent.PutExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING"); SendBroadcast(dwIntent); } e.Handled = true; }; ``` -------------------------------- ### Generated Android R Class Structure Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/Xamarin/Resources/AboutResources.txt Example of the R class structure generated by the build system to map resource files to integer constants. ```java public class R { public class drawable { public const int icon = 0x123; } public class layout { public const int main = 0x456; } public class strings { public const int first_string = 0xabc; public const int second_string = 0xbcd; } } ``` -------------------------------- ### DataWedge Intent Filter Configuration Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md Define the intent filter action in your strings.xml file to specify how your application receives DataWedge Intents. This example includes keys for source, label type, and data string. ```xml com.darryncampbell.datawedge.LANGUAGE.ACTION com.symbol.datawedge.source com.symbol.datawedge.label_type com.symbol.datawedge.data_string ``` -------------------------------- ### Control Scanner Programmatically with SOFT_SCAN_TRIGGER Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Use these snippets to trigger the barcode scanner start and stop actions via broadcast intents. Ensure the application has the appropriate permissions to send broadcasts to DataWedge. ```java // Java - Implement a soft scan button public boolean onTouch(View view, MotionEvent motionEvent) { if (view.getId() == R.id.btnScan) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { // Button pressed, start scan Intent dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); sendBroadcast(dwIntent); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { // Button released, stop scan Intent dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING"); sendBroadcast(dwIntent); } } return true; } ``` ```kotlin // Kotlin - Implement a soft scan button override fun onTouch(view: View?, motionEvent: MotionEvent?): Boolean { if (view?.getId() == R.id.btnScan) { if (motionEvent?.getAction() == MotionEvent.ACTION_DOWN) { val dwIntent = Intent() dwIntent.action = "com.symbol.datawedge.api.ACTION" dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING") sendBroadcast(dwIntent) } else if (motionEvent?.getAction() == MotionEvent.ACTION_UP) { val dwIntent = Intent() dwIntent.action = "com.symbol.datawedge.api.ACTION" dwIntent.putExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING") sendBroadcast(dwIntent) } } return true } ``` ```csharp // Xamarin C# - Implement a soft scan button btnScan.Touch += (s, e) => { if (e.Event.Action == MotionEventActions.Down) { Intent dwIntent = new Intent(); dwIntent.SetAction("com.symbol.datawedge.api.ACTION"); dwIntent.PutExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "START_SCANNING"); SendBroadcast(dwIntent); } else if (e.Event.Action == MotionEventActions.Up) { Intent dwIntent = new Intent(); dwIntent.SetAction("com.symbol.datawedge.api.ACTION"); dwIntent.PutExtra("com.symbol.datawedge.api.SOFT_SCAN_TRIGGER", "STOP_SCANNING"); SendBroadcast(dwIntent); } e.Handled = true; }; ``` -------------------------------- ### Process Scan Data in Java Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Use string resources to retrieve scan data from the DataWedge intent in your Java Android code. This example shows how to extract the decoded source, data, and label type. ```java // Java - Using string resources for intent keys private void displayScanResult(Intent scanIntent) { String decodedSource = scanIntent.getStringExtra(getResources().getString(R.string.datawedge_intent_key_source)); String decodedData = scanIntent.getStringExtra(getResources().getString(R.string.datawedge_intent_key_data)); String decodedLabelType = scanIntent.getStringExtra(getResources().getString(R.string.datawedge_intent_key_label_type)); // decodedSource: "scanner" (indicates barcode scanner was source) // decodedData: "1234567890128" (the actual barcode content) // decodedLabelType: "LABEL-TYPE-EAN13" (barcode symbology type) } ``` -------------------------------- ### Create a DataWedge Profile in Java Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Initializes a new DataWedge profile by broadcasting an intent with the CREATE_PROFILE action. ```java // Java - Create a new DataWedge profile private static final String ACTION_DATAWEDGE = "com.symbol.datawedge.api.ACTION"; private static final String EXTRA_CREATE_PROFILE = "com.symbol.datawedge.api.CREATE_PROFILE"; private static final String PROFILE_NAME = "MyAppProfile"; Intent dwIntent = new Intent(); dwIntent.setAction(ACTION_DATAWEDGE); dwIntent.putExtra(EXTRA_CREATE_PROFILE, PROFILE_NAME); context.sendBroadcast(dwIntent); ``` -------------------------------- ### Configure DataWedge Profile Settings in Java Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Configures barcode input, intent output, and keystroke output plugins for an existing profile. Each plugin requires a separate SET_CONFIG broadcast. ```java // Java - Complete profile configuration for barcode scanning with intent output // Step 1: Configure the barcode input plugin Bundle profileConfig = new Bundle(); profileConfig.putString("PROFILE_NAME", "MyAppProfile"); profileConfig.putString("PROFILE_ENABLED", "true"); profileConfig.putString("CONFIG_MODE", "UPDATE"); Bundle barcodeConfig = new Bundle(); barcodeConfig.putString("PLUGIN_NAME", "BARCODE"); barcodeConfig.putString("RESET_CONFIG", "true"); Bundle barcodeProps = new Bundle(); barcodeProps.putString("configure_all_scanners", "true"); barcodeProps.putString("scanner_input_enabled", "true"); barcodeConfig.putBundle("PARAM_LIST", barcodeProps); profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig); // Associate profile with your application Bundle appConfig = new Bundle(); appConfig.putString("PACKAGE_NAME", context.getPackageName()); appConfig.putStringArray("ACTIVITY_LIST", new String[]{"*"}); profileConfig.putParcelableArray("APP_LIST", new Bundle[]{appConfig}); Intent dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SET_CONFIG", profileConfig); context.sendBroadcast(dwIntent); // Step 2: Configure intent output plugin (must be separate call) profileConfig.remove("PLUGIN_CONFIG"); Bundle intentConfig = new Bundle(); intentConfig.putString("PLUGIN_NAME", "INTENT"); intentConfig.putString("RESET_CONFIG", "true"); Bundle intentProps = new Bundle(); intentProps.putString("intent_output_enabled", "true"); intentProps.putString("intent_action", "com.myapp.ACTION.BARCODE_SCAN"); intentProps.putString("intent_delivery", "0"); // 0 = StartActivity, 1 = StartService, 2 = Broadcast intentConfig.putBundle("PARAM_LIST", intentProps); profileConfig.putBundle("PLUGIN_CONFIG", intentConfig); dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SET_CONFIG", profileConfig); context.sendBroadcast(dwIntent); // Step 3: Disable keystroke output (optional, prevents barcode appearing as keystrokes) profileConfig.remove("PLUGIN_CONFIG"); Bundle keystrokeConfig = new Bundle(); keystrokeConfig.putString("PLUGIN_NAME", "KEYSTROKE"); keystrokeConfig.putString("RESET_CONFIG", "true"); Bundle keystrokeProps = new Bundle(); keystrokeProps.putString("keystroke_output_enabled", "false"); keystrokeConfig.putBundle("PARAM_LIST", keystrokeProps); profileConfig.putBundle("PLUGIN_CONFIG", keystrokeConfig); dwIntent = new Intent(); dwIntent.setAction("com.symbol.datawedge.api.ACTION"); dwIntent.putExtra("com.symbol.datawedge.api.SET_CONFIG", profileConfig); context.sendBroadcast(dwIntent); ``` -------------------------------- ### Configure DataWedge Profile with Java Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Encapsulates profile creation and plugin configuration into a single utility class. Requires Android context to broadcast intents to the DataWedge service. ```java // Java - DWUtilities.java complete implementation package com.myapp; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class DWUtilities { private static final String PROFILE_NAME = "MyAppProfile"; private static final String ACTION_DATAWEDGE = "com.symbol.datawedge.api.ACTION"; private static final String EXTRA_CREATE_PROFILE = "com.symbol.datawedge.api.CREATE_PROFILE"; private static final String EXTRA_SET_CONFIG = "com.symbol.datawedge.api.SET_CONFIG"; public static void CreateDWProfile(Context context) { // Create the profile sendDataWedgeIntentWithExtra(context, ACTION_DATAWEDGE, EXTRA_CREATE_PROFILE, PROFILE_NAME); // Configure barcode input plugin Bundle profileConfig = new Bundle(); profileConfig.putString("PROFILE_NAME", PROFILE_NAME); profileConfig.putString("PROFILE_ENABLED", "true"); profileConfig.putString("CONFIG_MODE", "UPDATE"); Bundle barcodeConfig = new Bundle(); barcodeConfig.putString("PLUGIN_NAME", "BARCODE"); barcodeConfig.putString("RESET_CONFIG", "true"); Bundle barcodeProps = new Bundle(); barcodeProps.putString("configure_all_scanners", "true"); barcodeProps.putString("scanner_input_enabled", "true"); barcodeConfig.putBundle("PARAM_LIST", barcodeProps); profileConfig.putBundle("PLUGIN_CONFIG", barcodeConfig); Bundle appConfig = new Bundle(); appConfig.putString("PACKAGE_NAME", context.getPackageName()); appConfig.putStringArray("ACTIVITY_LIST", new String[]{"*"}); profileConfig.putParcelableArray("APP_LIST", new Bundle[]{appConfig}); sendDataWedgeIntentWithExtra(context, ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig); // Configure intent output plugin profileConfig.remove("PLUGIN_CONFIG"); Bundle intentConfig = new Bundle(); intentConfig.putString("PLUGIN_NAME", "INTENT"); intentConfig.putString("RESET_CONFIG", "true"); Bundle intentProps = new Bundle(); intentProps.putString("intent_output_enabled", "true"); intentProps.putString("intent_action", "com.myapp.ACTION.BARCODE_SCAN"); intentProps.putString("intent_delivery", "0"); intentConfig.putBundle("PARAM_LIST", intentProps); profileConfig.putBundle("PLUGIN_CONFIG", intentConfig); sendDataWedgeIntentWithExtra(context, ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig); // Disable keystroke output profileConfig.remove("PLUGIN_CONFIG"); Bundle keystrokeConfig = new Bundle(); keystrokeConfig.putString("PLUGIN_NAME", "KEYSTROKE"); keystrokeConfig.putString("RESET_CONFIG", "true"); Bundle keystrokeProps = new Bundle(); keystrokeProps.putString("keystroke_output_enabled", "false"); keystrokeConfig.putBundle("PARAM_LIST", keystrokeProps); profileConfig.putBundle("PLUGIN_CONFIG", keystrokeConfig); sendDataWedgeIntentWithExtra(context, ACTION_DATAWEDGE, EXTRA_SET_CONFIG, profileConfig); } private static void sendDataWedgeIntentWithExtra(Context context, String action, String extraKey, String extraValue) { Intent dwIntent = new Intent(); dwIntent.setAction(action); dwIntent.putExtra(extraKey, extraValue); context.sendBroadcast(dwIntent); } private static void sendDataWedgeIntentWithExtra(Context context, String action, String extraKey, Bundle extras) { Intent dwIntent = new Intent(); dwIntent.setAction(action); dwIntent.putExtra(extraKey, extras); context.sendBroadcast(dwIntent); } } // Usage in MainActivity.onCreate() @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DWUtilities.CreateDWProfile(this); // Single call configures everything } ``` -------------------------------- ### Loading Font Files from Assets Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/Xamarin/Assets/AboutAssets.txt Load font files directly from the assets directory using Typeface.CreateFromAsset. Specify the correct path within the assets folder. ```java Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); ``` -------------------------------- ### Accessing Raw Assets in Android Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/Xamarin/Assets/AboutAssets.txt Place raw files in the assets directory and access them using Android's AssetManager. Ensure the file exists in the assets folder. ```csharp public class ReadAsset : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); InputStream input = Assets.Open ("my_asset.txt"); } } ``` -------------------------------- ### SET_CONFIG Intent Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Configures an existing DataWedge profile by applying plugin settings for barcode input, intent output, and keystroke output. ```APIDOC ## ACTION com.symbol.datawedge.api.SET_CONFIG ### Description Configures an existing DataWedge profile with specific plugin settings. Each plugin (BARCODE, INTENT, KEYSTROKE) must be configured via a separate intent call. ### Method Broadcast Intent ### Parameters #### Request Body - **PROFILE_NAME** (String) - Required - The name of the profile to update. - **PROFILE_ENABLED** (String) - Required - Set to "true" to enable the profile. - **CONFIG_MODE** (String) - Required - Set to "UPDATE". - **PLUGIN_CONFIG** (Bundle) - Required - Contains the configuration for specific plugins (BARCODE, INTENT, KEYSTROKE). - **APP_LIST** (Bundle[]) - Optional - Associates the profile with specific packages and activities. ``` -------------------------------- ### Configure AndroidManifest for Scan Data Reception Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Set the activity launchMode to singleTop to ensure existing instances handle incoming scan intents via onNewIntent(). ```xml ``` -------------------------------- ### CREATE_PROFILE Intent Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Creates a new DataWedge profile to manage scanner behavior for a specific application. ```APIDOC ## ACTION com.symbol.datawedge.api.CREATE_PROFILE ### Description Creates a new DataWedge profile that can be configured to control scanner behavior for your application. ### Method Broadcast Intent ### Parameters #### Request Body - **com.symbol.datawedge.api.CREATE_PROFILE** (String) - Required - The name of the profile to be created. ``` -------------------------------- ### Configure Activity Launch Mode Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md Set the launchMode to 'singleTop' in your AndroidManifest.xml to ensure the existing activity is reused when a new Intent is received. This is crucial for handling DataWedge Intents. ```xml android:launchMode="singleTop" ``` ```csharp LaunchMode=Android.Content.PM.LaunchMode.SingleTop) ``` -------------------------------- ### Process Scan Results in Kotlin Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Handle the incoming intent in onNewIntent() to extract barcode data, label type, and source information from the DataWedge scan result. ```kotlin // Kotlin - Process received barcode data override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) displayScanResult(intent) } private fun displayScanResult(scanIntent: Intent) { val decodedSource = scanIntent.getStringExtra("com.symbol.datawedge.source") val decodedData = scanIntent.getStringExtra("com.symbol.datawedge.data_string") val decodedLabelType = scanIntent.getStringExtra("com.symbol.datawedge.label_type") val scan = "$decodedData [$decodedLabelType]\n\n" val output = findViewById(R.id.txtOutput) output.text = scan + output.text } ``` -------------------------------- ### Process Scan Results in Java Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Handle the incoming intent in onNewIntent() to extract barcode data, label type, and source information from the DataWedge scan result. ```java // Java - Process received barcode data @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); displayScanResult(intent); } private void displayScanResult(Intent scanIntent) { // Extract barcode data from intent extras String decodedSource = scanIntent.getStringExtra("com.symbol.datawedge.source"); String decodedData = scanIntent.getStringExtra("com.symbol.datawedge.data_string"); String decodedLabelType = scanIntent.getStringExtra("com.symbol.datawedge.label_type"); // Display the result String scan = decodedData + " [" + decodedLabelType + "]\n\n"; TextView output = findViewById(R.id.txtOutput); output.setText(scan + output.getText()); } ``` -------------------------------- ### Handle Incoming Scan Data Intent in Kotlin Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md Use the onNewIntent() method in your Kotlin Activity to receive and process DataWedge scan data from an Intent. This snippet shows how to retrieve scan details and append them to a TextView. ```kotlin override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) val decodedData = scanIntent.getStringExtra(resources.getString(R.string.datawedge_intent_key_data)) val decodedLabelType = scanIntent.getStringExtra(resources.getString(R.string.datawedge_intent_key_label_type)) val scan = "$decodedData [$decodedLabelType]\n\n" val output = findViewById(R.id.txtOutput) output.text = scan + output.text } ``` -------------------------------- ### Handle Incoming Scan Data Intent in Xamarin Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md This C# code for Xamarin demonstrates how to override the OnNewIntent method to capture and display DataWedge scan data. It retrieves the decoded data and label type from the Intent and updates a TextView. ```csharp protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); String decodedData = scanIntent.GetStringExtra(Resources.GetString(Resource.String.datawedge_intent_key_data)); String decodedLabelType = scanIntent.GetStringExtra(Resources.GetString(Resource.String.datawedge_intent_key_label_type)); String scan = decodedData + " [" + decodedLabelType + "]\n\n"; TextView output = FindViewById(Resource.Id.txtOutput); output.Text = scan + output.Text; } ``` -------------------------------- ### Handle Incoming Scan Data Intent in Java Source: https://github.com/darryncampbell/datawedge-gettingstarted-samples/blob/master/README.md Implement the onNewIntent() method in your Java Activity to process DataWedge scan data received via an Intent. This method extracts decoded data and label type, then updates a TextView. ```java @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String decodedData = scanIntent.getStringExtra(getResources().getString(R.string.datawedge_intent_key_data)); String decodedLabelType = scanIntent.getStringExtra(getResources().getString(R.string.datawedge_intent_key_label_type)); String scan = decodedData + " [" + decodedLabelType + "]\n\n"; final TextView output = findViewById(R.id.txtOutput); output.setText(scan + output.getText()); } ``` -------------------------------- ### Define Intent Keys in strings.xml Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Define intent keys as string resources in your Android application's strings.xml file. Ensure the 'activity_intent_filter_action' matches the DataWedge profile configuration. ```xml My Barcode Scanner com.myapp.ACTION.BARCODE_SCAN com.symbol.datawedge.source com.symbol.datawedge.label_type com.symbol.datawedge.data_string ``` -------------------------------- ### Process Scan Results in Xamarin C# Source: https://context7.com/darryncampbell/datawedge-gettingstarted-samples/llms.txt Handle the incoming intent in OnNewIntent() to extract barcode data, label type, and source information from the DataWedge scan result. ```csharp // Xamarin C# - Process received barcode data protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); DisplayScanResult(intent); } private void DisplayScanResult(Intent scanIntent) { String decodedSource = scanIntent.GetStringExtra("com.symbol.datawedge.source"); String decodedData = scanIntent.GetStringExtra("com.symbol.datawedge.data_string"); String decodedLabelType = scanIntent.GetStringExtra("com.symbol.datawedge.label_type"); String scan = decodedData + " [" + decodedLabelType + "]\n\n"; TextView output = FindViewById(Resource.Id.txtOutput); output.Text = scan + output.Text; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.