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.
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:
Power
To get information about the battery, Xamarin broadcasts the Intent
ActionBatteryChanged 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 SendStickyBroadcast .
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:
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 providing the class NfcManager , here how to use it:
Notifications
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.
*Please notice that not all LEDs on a device can be freely controlled by a user application, as some are reserved to the system.
Touch
The class TouchManager can be used to lock the touchscreen.
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.
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.
Reset
With the class PowerManager is possible to perform several type of resets and reboot of the device.
EnterpriseReset and FactoryReset reset types clear the configuration of the device setting it to a custom one or to the out-of-the-box one respectively, while Reset is a software reboot of the device.