Class: Battery

domain/Battery.Battery

Constructors

constructor

new Battery(health?, plugged?, status?, capacity?)

Class representing the device’s battery health, status and plugged state. See https://developer.android.com/reference/android/os/BatteryManager for more information.

Parameters

Name

Type

Description

health?

BatteryHealth

the battery’s health (either UNKNOWN, GOOD, OVERHEAT, DEAD, OVER_VOLTAGE, UNSPECIFIED_FAILURE, COLD)

plugged?

BatteryPlugged

the battery’s plugged status (either DOCK, AC, USB, WIRELESS)

status?

BatteryStatus

the battery’s status (either UNKNOWN, CHARGING, DISCHARGING, NOT_CHARGING, FULL)

capacity?

number

Remaining battery capacity as an integer percentage of total capacity (with no fractional part).

Properties

capacity

Optional capacity: number

Remaining battery capacity as an integer percentage of total capacity (with no fractional part).


health

Optional health: BatteryHealth

the battery’s health (either UNKNOWN, GOOD, OVERHEAT, DEAD, OVER_VOLTAGE, UNSPECIFIED_FAILURE, COLD)


plugged

Optional plugged: BatteryPlugged

the battery’s plugged status (either DOCK, AC, USB, WIRELESS)


status

Optional status: BatteryStatus

the battery’s status (either UNKNOWN, CHARGING, DISCHARGING, NOT_CHARGING, FULL)

Methods

fromJSON

Static fromJSON(battery): Battery

Create from JSON

Parameters

Name

Type

Description

battery

any

JSON object

Returns

Battery