java.lang.Object | |
↳ | com.datalogic.device.battery.DLBatteryManager |
The DLBatteryManager
allows to read specific battery parameters.
Lifetime and realtime values can be read through the BatteryStatus
and manufacturer information can be read through the ManufacturerInfo
. This class is also used to retrieve information and setup the current charging profile between the ones available, through the ChargingProfile
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers a
BatteryEventListener to be notified of the BatteryManager events. | |||||||||||
Reads the battery status.
| |||||||||||
Gets the current charging profile setup in this device.
| |||||||||||
Returns an instance of the
DLBatteryManager . | |||||||||||
Reads the integer value of a specific battery property.
| |||||||||||
Reads the battery manufacturer info.
| |||||||||||
Reads the String value of a specific battery property.
| |||||||||||
Gets the supported charging profiles in this device.
| |||||||||||
Prepare the DlBatteryManager to receive events from the Android PowerManger Service.
| |||||||||||
Unregisters a
BatteryEventListener associated with the BatteryManager. | |||||||||||
Sets the current charging profile.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Registers a BatteryEventListener
to be notified of the BatteryManager events.
A call to addBatteryEventListener will fail with error CONTEXT_UNKNOWN
if initBatteryEvents(Context)
has not been not previously called to register the client's context.
Call removeBatteryEventListener(BatteryEventListener)
before the application
closes to properly shut down the listener and avoid memory leaks.
listener | The BatteryEventListener that will be called to signal a BatteryEvent |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the BatteryException
error constants.BatteryException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Reads the battery status.
BatteryStatus
object containing all battery status.
Gets the current charging profile setup in this device.
ChargingProfile
currently setup in this device.
Returns an instance of the DLBatteryManager
.
Reads the integer value of a specific battery property. This value is present
as one of the properties of the BatteryInfo
. Call this method only with
BatteryInfo
related to properties of type int
. For
properties of type String
, use getStringProperty() instead.
prop | The required BatteryInfo . |
---|
int
The value of the specified property, or throws an
Exception
in case of failure.
Reads the battery manufacturer info.
ManufacturerInfo
object containing all battery manufacturer info.
Reads the String value of a specific battery property. This value is present
as one of the properties of the BatteryInfo
. Call this method only with
BatteryInfo
related to properties of type String
. For
properties of type int
, call getIntProperty() instead.
prop | The required BatteryInfo . |
---|
String
The value of the specified property, or throws an
Exception
in case of failure.
Gets the supported charging profiles in this device. You can use one of the returning objects to setup the desired charging profile.
ChargingProfile
objects, each representing one of the supported charging profile.
The list can be empty in case no charging profile is supported in the
current device.
Prepare the DlBatteryManager to receive events from the Android PowerManger Service.
If not called the addBatteryEventListener(BatteryEventListener)
fails with error CONTEXT_UNKNOWN
.
This method cannot be called from a BroadcastReceiver component; that is, from a BroadcastReceiver that is declared
in an application's manifest. It is okay, however, to call this method from another BroadcastReceiver that has itself
been registered at run time with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of such a
registered BroadcastReceiver is tied to the object that registered it. See for more details:
registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
and
ReceiverCallNotAllowedException
context | The context of the caller. |
---|
BatteryException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Unregisters a BatteryEventListener
associated with the BatteryManager.
listener | The BatteryEventListener that will be no more notified. |
---|
int
SUCCESS
in case of success,
otherwise a possible error code, matching one of the BatteryException
error constants.BatteryException | in case of error, when exceptions are enabled through the ErrorManager singleton.
|
---|
Sets the current charging profile. This setting is persistent to device reboots or even factory resets.
chargingProfile | The ChargingProfile
to set.
|
---|