Skip to main content

Frequently Asked Questions

How can I receive barcode data in my app?

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 Activity.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().

How can I configure Decoder properties?

To configure the decoder properties, you need to instantiate BarcodeManager and get a ScannerProperties instance.

BarcodeManager manager = null;
ScannerProperties configuration = null;
...
manager = new BarcodeManager();
...
configuration = ScannerProperties.Edit(manager);

Properties are organized hierarchically. Each property has the method Set that requires a different argument depending on the property type (i.e.: int, boolean, String, etc...):

configuration.Code39.EnableChecksum.Set(true);
configuration.Code39.FullAscii.Set(true);
configuration.Code39.Length1.Set(20);
...
configuration.code39.userID.set('x');
...
if (configuration.QrCode.IsSupported)
{
configuration.QrCode.Enable.Set(false);
}

For the configuration to be actually applied, you must call the ScannerProperties' Store method:

configuration.Store(manager, true);

How can I retrieve device information?

The Datalogic Android SDK provides many common operations done on an Android device to gather information.

Info

The Datalogic Xamarin SDK provides advanced information about the device in the class SYSTEM, which exposes Wi-Fi type, keyboard type and others as static members.

Example usage:

Com.Datalogic.Device.Info.SYSTEM.SdkVersionInt;

Power

To get information about the battery, Xamarin broadcasts the Intent ActionBatteryChanged, which can carry information in its extra properties. The intent is fired every time the status of the battery changes and once when you register a receiver, notice that this particular behavior happens because the battery intent is a STICKY one: SendStickyBroadcast.

Intent currentBatteryStatus = RegisterReceiver(null, new IntentFilter(
Android.Content.Intent.ActionBatteryChanged));

Location

The standard Android SDK doesn't allow turning on or off the Location providers (GPS, network, etc...), thus an application must ask to the user to manually do it. Datalogic SDK overcome this limit by providing the class LocationManager. Here's how to use it:

Com.Datalogic.Device.Location.LocationManager loc = null;
try
{
loc = new Com.Datalogic.Device.Location.LocationManager();
loc.setLocationMode(enable ? LocationMode.SensorsAndNetwork : LocationMode.Off);
}
catch (DeviceException e)
{
Log.Error(this.LocalClassName, "Exception while switching location mode ", e);
}

NFC

Standard Android SDK doesn't allow to turn on or off the NFC adapter, thus an application must ask to the user to manually do it. Datalogic SDK overcomes this limit by providing the class NfcManager.

Example usage:

NfcManager nfc = new Com.Datalogic.Device.Nfc.NfcManager();
nfc.EnableNfcAdapter(enable);

Notifications

Datalogic SDK allows to control LEDs on the device. However, not all LEDs on a device can be freely controlled by a user application; some are reserved to the system. The standard Android APIs for controlling the notification LED via the notifications system still works, though you are limited to 1 LED, while Datalogic devices may have more LEDs, and it is easier to control them using the LedManager class than the standard API.

LedManager led = new LedManager();
led.blinkLed(Led.LedGreenSpot, 1, 500, 500);

Touch

The TouchManager class can be used to lock the touchscreen.

TouchManager tm = new TouchManager();
tm.lockInput(true);
Thread.sleep(2000);
tm.lockInput(false);

Sleep and Wakeup

The PowerManager class allows one to configure screen timeout and wakeup sources for the device. SuspendTimeout using the SetSuspendTimeout method.

PowerManager pm = new PowerManager();

pm.SetSuspendTimeout(SuspendTimeout.Minutes5, false); // battery

pm.SetSuspendTimeout(SuspendTimeout.Never, true); // ext power

Please note that not all the WakeupSource values available in the SDK are supported by a device, thus it is better to check if they are supported before enabling/disabling them.

if (pm.isWakeupSupported(WakeupSource.TrigLeft) &&
!pm.isWakeupActive(WakeupSource.TrigLeft)) {
pm.activateWakeup(WakeupSource.TrigLeft);
}

Reset

The PowerManager class allows you to perform several types of resets and reboots of the device.

  • EnterpriseReset - clear device configuration and perform a "Enterprise" reset
  • FactoryReset - clear device configuration and perform an out-of-the-box level factory reset. reset types
  • Reset - perform a software reboot of the device.

How can I access the self-shopping cradle?

Cradle State

Access details such as whether or not the device is in a cradle, the cradle's version, device insertion count, slot index, and whether or not fast charging is supported. These details are stored in the StateInfo class.

Example usage:

ICradleJoyaTouch jtCradle  = (ICradleJoyaTouch) CradleManager.Cradle;

StateInfo state = new StateInfo();
if (jtCradle.GetCradleState(state))
string insCount = "Insertion count: " + state.InsertionCount;

Cradle LEDs

Change the state of the LEDs on the cradle by using the LedAction class.

Example usage:

ICradleJoyaTouch jtCradle  = (ICradleJoyaTouch) CradleManager.Cradle;
jtCradle.ControlLed(LedAction.BlinkSlow);

Cradle Lock

Change the state of the cradle lock using the LockAction class.

Example usage:

ICradleJoyaTouch jtCradle  = (ICradleJoyaTouch) CradleManager.Cradle;
jtCradle.ControlLock(Action.UnlockWithLedOn);

Cradle Config Area

Use the ConfigArea class to access the current cradle slot's configuration area, consisting of an array of bytes. Also, an exposed method allows to get or set the fast charge value contained in one of the bytes of the configuration area.

ICradleJoyaTouch jtCradle  = (ICradleJoyaTouch) CradleManager.Cradle;
ConfigArea config = new ConfigArea();
byte[] configValues;
if (jtCradle.ReadConfigArea(config))
{
configValues = config.GetContent();
}

Cradle Custom Area

Use the CustomArea class to access the custom data area of the cradle slot being occupied.

ICradleJoyaTouch jtCradle  = (ICradleJoyaTouch) CradleManager.Cradle;
CustomArea custom = new CustomArea();
byte[] customValues;
if (jtCradle.ReadCustomArea(custom, custom.Size))
{
customValues = custom.GetContent();
}