Constants
The Battery API, which belongs to the voltmx.os Namespace, contains the following types of constants.
Battery State Constants
These constants specify the current state of the device battery.
Constant | Description |
---|---|
BATTERY_STATE_CHARGING | Indicates that the state of the device battery as being charged. |
BATTERY_STATE_DISCHARGING | Indicates that the state of the device battery as being discharged. |
BATTERY_STATE_FULL | Indicates that the state of the device battery charge is completely full. |
BATTERY_STATE_UNKNOWN | Indicates that the state of the device battery charge as not known. |
Example
When you query for the state of the device battery as shown in this example, any of the four available battery states is returned.
var batteryState = voltmx.os.getBatteryState();
if (voltmx.os.BATTERY_STATE_CHARGING == batteryState) {
voltmx.print(“Battery State: Charging”);
}
Platform Availability
- iOS
- Android
- Windows