Device Sample API

This tutorial shows common operations done on an Android device to gather information. The sample app is divided into several Activities, one per each topic.


Datalogic 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:;


To get information about the battery, Android broadcasts the Intent  Intent.ACTION_BATTERY_CHANGED() which 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  Context.sendStickyBroadcast() .

Intent currentBatteryStatus = registerReceiver(null, new IntentFilter(


Standard Android SDK doesn't allow to turn 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 providing the class  LocationManager , here how to use it:

com.datalogic.device.location.LocationManager loc = null;
try {
    loc = new com.datalogic.device.location.LocationManager();
    loc.setLocationMode(enable ? LocationMode.NETWORK : LocationMode.OFF);
} catch (DeviceException e) {


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 providing the class  NfcManager , here how to use it:

NfcManager nfc = new com.datalogic.device.nfc.NfcManager();


Datalogic SDK allows to control LEDs on the device (*). 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, moreover using Datalogic  LedManager the control is easier.

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

*Please notice that not all LEDs on a device can be freely controlled by a user application, as some are reserved to the system.


The class  TouchManager can be used to lock the touchscreen.

TouchManager tm = new TouchManager();

Sleep and Wakeup

Datalogic  PowerManager allows to configure the screen off timeout and the wakeup sources of the device.

The  SuspendTimeout can be set with a condition: the device running on battery or the device plugged to a power source, the function  PowerManager.setSuspendTimeout() has a boolean argument for it.

PowerManager pm = new PowerManager();

pm.setSuspendTimeout(SuspendTimeout.MINUTES_5, false); // battery
pm.setSuspendTimeout(SuspendTimeout.NEVER, true); // ext power

Please notice that not all the  WakeupSource s available in the SDK are supported by a device, thus is better to check for the support before enabling/disabling them.

if (pm.isWakeupSupported(WakeupSource.TRIG_LEFT) &&
        !pm.isWakeupActive(WakeupSource.TRIG_LEFT)) {


With the class  PowerManager is possible to perform several type of resets and reboot of the device.

 BootType.ENTERPRISE_RESET() and  BootType.FACTORY_RESET() reset types clear the configuration of the device setting it to a custom one or to the out-of-the-box one respectively, while  BootType.RESET() is a software reboot of the device.