BatteryState
public
abstract
class
BatteryState
extends Object
java.lang.Object | |
↳ | android.hardware.BatteryState |
The BatteryState class is a representation of a single battery on a device.
Summary
Constants | |
---|---|
int |
STATUS_CHARGING
Battery is charging. |
int |
STATUS_DISCHARGING
Battery is discharging. |
int |
STATUS_FULL
Battery is full. |
int |
STATUS_NOT_CHARGING
Battery is connected to power but not charging. |
int |
STATUS_UNKNOWN
Battery status is unknown. |
Public constructors | |
---|---|
BatteryState()
|
Public methods | |
---|---|
abstract
float
|
getCapacity()
Get remaining battery capacity as float percentage [0.0f, 1.0f] of total capacity Returns NaN when battery capacity can't be read. |
abstract
int
|
getStatus()
Get the battery status. |
abstract
boolean
|
isPresent()
Check whether the hardware has a battery. |
Inherited methods | |
---|---|
Constants
STATUS_CHARGING
public static final int STATUS_CHARGING
Battery is charging.
Constant Value: 2 (0x00000002)
STATUS_DISCHARGING
public static final int STATUS_DISCHARGING
Battery is discharging.
Constant Value: 3 (0x00000003)
STATUS_FULL
public static final int STATUS_FULL
Battery is full.
Constant Value: 5 (0x00000005)
STATUS_NOT_CHARGING
public static final int STATUS_NOT_CHARGING
Battery is connected to power but not charging.
Constant Value: 4 (0x00000004)
STATUS_UNKNOWN
public static final int STATUS_UNKNOWN
Battery status is unknown.
Constant Value: 1 (0x00000001)
Public constructors
BatteryState
public BatteryState ()
Public methods
getCapacity
public abstract float getCapacity ()
Get remaining battery capacity as float percentage [0.0f, 1.0f] of total capacity Returns NaN when battery capacity can't be read.
Returns | |
---|---|
float |
the battery capacity. Value is between -1.0f and 1.0f inclusive |
getStatus
public abstract int getStatus ()
Get the battery status.
Returns | |
---|---|
int |
the battery status.
Value is STATUS_UNKNOWN , STATUS_CHARGING , STATUS_DISCHARGING , STATUS_NOT_CHARGING , or STATUS_FULL |
isPresent
public abstract boolean isPresent ()
Check whether the hardware has a battery.
Returns | |
---|---|
boolean |
True if the hardware has a battery, else false. |