I'm developing an app for Android using Xamarin and EMDK for a Zebra TC51.
The problem is I'm able to trigger the barcode scanner (using the physical button) only once. After that, the scanner does not run anymore.
What can be the cause of that? What can I check to have a diagnostic?
Extract of the code:
Tracking of the status:
scanner.Status += ( s, e ) =>
{
try
{
StatusData statusData = e.P0;
StatusData.ScannerStates state = e.P0.State;
this.RunOnUiThread( () => StateMessage( "Scanner state : " + state.Name() ) );
}
catch ( System.Exception exc )
{
this.RunOnUiThread( () => StateMessage( "Scanner state exception : " + exc.Message ) );
}
};
and for received data:
scanner.Data += ( s, e ) =>
{
try
{
var statusData = e.P0;
var scanData = e.P0.GetScanData();
foreach ( var sd in scanData )
{
this.RunOnUiThread( () => StateMessage( "Scanned : " + sd.Data ) );
}
}
catch ( System.Exception exc )
{
this.RunOnUiThread( () => StateMessage( "Scanner data exception : " + exc.Message ) );
}
};
The state sequence I can trace is the following:
After that nothing. The result is the same if I effectively read a barcode (and I can read it once) or not (just triggering the button).
you need to call read() again every time the scanner goes into the IDLE state to enable continuous scanning. There is a Xamarin sample app that you should be able to follow at https://github.com/Zebra/samples-emdkforxamarin-2_5/blob/BarcodeSample1/BarcodeSample1/BarcodeSample1/MainActivity.cs