Xamarin and DataWedge Intent API

M Mattia Durli 3 years ago
185 2 0

Hello, I successfully managed to use the DataWedge intent API to scan barcode through this articles and samples:
https://developer.zebra.com/community/home/blog/2018/07/11/xamarinforms-...
https://developer.zebra.com/community/home/blog/2018/07/24/tutorial-scan...
My problems are:
1) I want to use the MultiBarcode of NG Simulscan on a Zebra TC52.
If I set MultiBarcode and Instant Reporting manually in my DataWedge profile, it works and my app receives the multiple barcodes.
But I'm unable to set it programmatically.
I added the relevant code here, but scanning_mode and instant_reporting_enable doesn't seem to pass:
ZebraScannerConfig config = (ZebraScannerConfig)a_config;
Bundle profileConfig = new Bundle();
profileConfig.PutString("PROFILE_NAME", EXTRA_PROFILE_NAME);
profileConfig.PutString("PROFILE_ENABLED", _bRegistered ? "true" : "false"); // Seems these are all strings
profileConfig.PutString("CONFIG_MODE", "UPDATE");
Bundle barcodeConfig = new Bundle();
barcodeConfig.PutString("PLUGIN_NAME", "BARCODE");
barcodeConfig.PutString("RESET_CONFIG", "false"); // This is the default but never hurts to specify
Bundle barcodeProps = new Bundle();
barcodeProps.PutString("scanner_input_enabled", "true");
barcodeProps.PutString("scanner_selection", "auto"); // Could also specify a number here, the id returned from ENUMERATE_SCANNERS.
barcodeProps.PutString("scanning_mode", "3");
barcodeProps.PutString("instant_reporting_enable", "true");
barcodeConfig.PutBundle("PARAM_LIST", barcodeProps);
profileConfig.PutBundle("PLUGIN_CONFIG", barcodeConfig);
Bundle appConfig = new Bundle();
appConfig.PutString("PACKAGE_NAME", Android.App.Application.Context.PackageName); // Associate the profile with this app
appConfig.PutStringArray("ACTIVITY_LIST", new String[] { "*" });
profileConfig.PutParcelableArray("APP_LIST", new Bundle[] { appConfig });
SendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2, EXTRA_SET_CONFIG, profileConfig);
2) I want to enable the Scanner StatusChange notification API, that is present in the mentioned sample, but not implemented:
private void ScannedStatusChanged(object sender, string a_message)
{
string status = a_message;
}
I tried to follow the API Documentation, but is all Java and samples are all in Java (some Xamarin Datawedge API samples ar really missing).
So I added this to the SetConfig:
Bundle notificationConfig = new Bundle();
notificationConfig.PutString("PACKAGE_NAME", Android.App.Application.Context.PackageName);
notificationConfig.PutString("NOTIFICATION_TYPE", "SCANNER_STATUS");
SendDataWedgeIntentWithExtra(ACTION_DATAWEDGE_FROM_6_2,"com.symbol.datawedge.api.REGISTER_FOR_NOTIFICATION", notificationConfig);
but then how do I register the intent? I tried to Register to the same broadcast receiver both the Scan Intent and the Status intent, is it the correct way? Or should I have two different Broadcast receivers, one for the scan and the other for status notification?
if ((null != _broadcastReceiver) && (null != _context))
{
// Register the broadcast receiver
IntentFilter filterScan = new IntentFilter(DataWedgeReceiver.IntentActionScan);
filterScan.AddCategory(DataWedgeReceiver.IntentCategory);
_context.RegisterReceiver(_broadcastReceiver, filterScan);
IntentFilter filterStatus = new IntentFilter(DataWedgeReceiver.IntentActionStatus);
filterStatus.AddCategory(DataWedgeReceiver.IntentCategory);
_context.RegisterReceiver(_broadcastReceiver, filterStatus);
_bRegistered = true;
}
Essentially, using MultiBarcode, I need my app to be notified when the user releases th hard trigger.
Thanks,
Mattia

Please register or login to post a reply

2 Replies

D Darryn Campbell

Are you extracting the com.symbol.datawedge.barcodes extra?
https://github.com/darryncampbell/DataWedge-MultiBarcode-Sample/blob/mas...
My sample casts this as a List so I double-checked the DataWedge source code and this is an ArrayList so you should be able to cast this to https://docs.microsoft.com/en-us/dotnet/api/java.util.arraylist?view=xa…;

D Darryn Campbell

Please accept my apologies in advance but I do not have any Xamarin samples that specifically address your questions.
1.  I saw this myself and it stumped me for a while.  In the end I realised you need to specify which scanner you are using (you cannot use auto).  I am still unsure exactly why this is, I guess it was because not all scanners support instant reporting.  Example is here: https://github.com/darryncampbell/DataWedge-MultiBarcode-Sample/blob/mas...
2. There is a sample showing how to register for scanner notifications here: https://github.com/darryncampbell/DataWedge-Quick-Suspend-Scanner/blob/m...
Hope that helps,
Darryn.

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