Hi I am implementing a barcode scanning application in Xamarin for Android 8.1 and have implemented the code at https://techdocs.zebra.com/emdk-for-xamarin/6-0/tutorial/barcodeapitutor... with Symbol.XamarinEMDK (Zebra) NuGet package v18.104.22.168
The app has a menu which allows you to open various Activities which then allows barcode scanning for different types of products.When the activity opens it runs the code above to initialize the scanner and it mostly appears to work.
However have been having issues with the scanner sometimes not Initializing correctly. The problem appears to be in the InitScanner() method in the example.
//Attahch the Data Event handler to get the data callbacks.
scanner.Data += scanner_Data;
//Attach Scanner Status Event to get the status callbacks.
scanner.Status += scanner_Status;
//EMDK: Configure the scanner settings
ScannerConfig config = scanner.GetConfig();
config.SkipOnUnsupported = ScannerConfig.SkipOnUnSupported.None;
config.ScanParams.DecodeLEDFeedback = true;
config.ReaderParams.ReaderSpecific.ImagerSpecific.PickList = ScannerConfig.PickList.Enabled;
config.DecoderParams.Code39.Enabled = true;
config.DecoderParams.Code128.Enabled = false;
All works well until you get to the last line where it sets the config. This line works sometimes, but very regularly it returns the following error
Already scanning. Wait for current scanning to complete.
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <064cde681fba4dd08eaf8b1bdbbfb8c8>:0
at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <88e07771519044019747330a4a2ef026>:0
at Symbol.XamarinEMDK.Barcode.Scanner.SetConfig (Symbol.XamarinEMDK.Barcode.ScannerConfig p0) [0x0005b] in <ed07d706a8e748c482573c724434c6e6>:0
at Scanner.ScanActivity.InitScanner () [0x00106] in C:\Users\Andy\Source\Repos\AusPork\Ops 2\Scanner\ScanActivity.cs:86
--- End of managed Symbol.XamarinEMDK.Barcode.ScannerException stack trace ---
com.symbol.emdk.barcode.ScannerException: Already scanning. Wait for current scanning to complete.
However if you check the Status event it is not scanning, and certainly no button has been pressed on the scanner to do a scan.
Given the code I have matches the example on the link except that I am opening an Activity to get to this code, Is this a known bug or is there something else that needs to be added to properly SetConfig or reset the Scanning status?
The end result is that after this error sometimes the scanner works perfectly, and others it will scan but is unable to send data to the data event handler and so no scanning appears to happen.