Decode Listener
Register an IReadListener in your Activity.OnResume()
to receive read events on successful barcode reads:
protected override void OnResume()
{
base.OnResume();
if (decoder == null)
{
decoder = new BarcodeManager();
}
try
{
decoder.AddReadListener(this);
}
catch (DecodeException e)
{
Log.Error(LOGTAG, "Error while trying to bind a listener to BarcodeManager", e);
}
}
Unregister the IReadListener in your Acvivity.onPause()
:
protected override void OnPause()
{
base.OnPause();
if (decoder != null)
{
try
{
decoder.RemoveReadListener(this);
}
catch (Exception e)
{
Log.Error(LOGTAG, "Error while trying to remove a listener from BarcodeManager", e);
}
}
}
The actual barcode scanning is started via any physical scan trigger on the device. Though to start scanning when a button on the application is pressed, you need to call BarcodeManager.StartDecode() .