BatteryState
abstract class BatteryState
| kotlin.Any | |
| ↳ | android.hardware.BatteryState |
The BatteryState class is a representation of a single battery on a device.
Summary
| Constants | |
|---|---|
| static Int |
Battery is charging. |
| static Int |
Battery is discharging. |
| static Int |
Battery is full. |
| static Int |
Battery is connected to power but not charging. |
| static Int |
Battery status is unknown. |
| Public constructors | |
|---|---|
| Public methods | |
|---|---|
| abstract Float |
Get remaining battery capacity as float percentage [0. |
| abstract Int |
Get the battery status. |
| abstract Boolean |
Check whether the hardware has a battery. |
Constants
STATUS_DISCHARGING
static val STATUS_DISCHARGING: Int
Battery is discharging.
Value: 3STATUS_NOT_CHARGING
static val STATUS_NOT_CHARGING: Int
Battery is connected to power but not charging.
Value: 4STATUS_UNKNOWN
static val STATUS_UNKNOWN: Int
Battery status is unknown.
Value: 1Public constructors
BatteryState
BatteryState()
Public methods
getCapacity
abstract fun getCapacity(): Float
Get remaining battery capacity as float percentage [0.0f, 1.0f] of total capacity Returns NaN when battery capacity can't be read.
| Return | |
|---|---|
Float |
the battery capacity. Value is between -1.0f and 1.0f inclusive |
getStatus
abstract fun getStatus(): Int
Get the battery status.
isPresent
abstract fun isPresent(): Boolean
Check whether the hardware has a battery.
| Return | |
|---|---|
Boolean |
True if the hardware has a battery, else false. |