Skip to content

SL4A BatteryManagerFacade

michael edited this page Nov 9, 2015 · 1 revision

Exposes Batterymanager API. Note that in order to use any of the batteryGet* functions, you need to batteryStartMonitoring, and then wait for a "battery" event. Sleeping for a second will usually work just as well.


batteryCheckPresent Returns the most recently received battery presence data.
Min SDK level=5
batteryGetHealth Returns the most recently received battery health data:
1 - unknown;
2 - good;
3 - overheat;
4 - dead;
5 - over voltage;
6 - unspecified failure;
batteryGetLevel Returns the most recently received battery level (percentage).
Min SDK level=5
batteryGetPlugType Returns the most recently received plug type data:
-1 - unknown
0 - unplugged;
1 - power source is an AC charger
2 - power source is a USB port
batteryGetStatus Returns the most recently received battery status data:
1 - unknown;
2 - charging;
3 - discharging;
4 - not charging;
5 - full;
batteryGetTechnology Returns the most recently received battery technology data.
Min SDK level=5
batteryGetTemperature Returns the most recently received battery temperature.
Min SDK level=5
batteryGetVoltage Returns the most recently received battery voltage.
Min SDK level=5
batteryStartMonitoring Starts tracking battery state.
throws "battery" events
batteryStopMonitoring Stops tracking battery state.
readBatteryData Returns the most recently recorded battery data.
Clone this wiki locally