public class BatteryInfo extends Object
Battery information includes the remaining battery power, voltage, temperature, model, and charger type.
SystemCapability.PowerMgr#BATTERY_MANAGER| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
BatteryInfo.BatteryChargeState |
Indicates the battery charging status of a device.
|
static class |
BatteryInfo.BatteryHealthState |
Indicates the battery health status of a device.
|
static class |
BatteryInfo.BatteryLevel |
Indicates the battery charge level of a device.
|
static class |
BatteryInfo.BatteryPluggedType |
Indicates the charger type of a device.
|
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
OHOS_BATTERY_CAPACITY |
Indicates battery capacity.
|
static String |
OHOS_BATTERY_LOW |
Indicates the current battery power is low.
|
static String |
OHOS_BATTERY_PRESENT |
Whether the battery is present.
|
static String |
OHOS_BATTERY_TECHNOLOGY |
Indicates battery technology.
|
static String |
OHOS_BATTERY_TEMPERATURE |
Indicates battery current temperature.
|
static String |
OHOS_BATTERY_VOLTAGE |
Indicates battery current voltage.
|
static String |
OHOS_CHARGE_COUNTER |
Indicates the value of coulometer.
|
static String |
OHOS_CHARGE_STATE |
Indicates charging state.
|
static String |
OHOS_CHARGE_TYPE |
Indicates current charger type.
|
static String |
OHOS_CHARGING_CURRENT_MAX |
Indicates the maximum charging current of the battery.
|
static String |
OHOS_CHARGING_VOLTAGE_MAX |
Indicates the maximum voltage of the battery.
|
static String |
OHOS_TEMPERATURE_STATE |
Indicates current battery health status.
|
| 构造器 | 说明 |
|---|---|
BatteryInfo() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
BatteryInfo.BatteryLevel |
getBatteryLevel() |
Obtains the battery charge level of a device.
|
int |
getBatteryTemperature() |
Obtains the battery temperature (Celsius) of a device.
|
int |
getCapacity() |
Obtains the remaining battery power of a device.
|
BatteryInfo.BatteryChargeState |
getChargingStatus() |
Obtains the battery charging status of a device.
|
BatteryInfo.BatteryHealthState |
getHealthStatus() |
Obtains the battery health status of a device.
|
BatteryInfo.BatteryPluggedType |
getPluggedType() |
Obtains the charger type of a device.
|
boolean |
getPresent() |
Checks whether the battery of a device is present.
|
String |
getTechnology() |
Obtains the battery model of a device.
|
int |
getVoltage() |
Obtains the battery voltage (mV) of a device.
|
public static final String OHOS_BATTERY_CAPACITY
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the battery capacity.
public static final String OHOS_BATTERY_LOW
This constant is a keyword used to extract a boolean variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The boolean variable contains information about whether the battery power is low.
public static final String OHOS_BATTERY_PRESENT
This constant is a keyword used to extract a boolean variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The boolean variable contains information about whether the battery is present.
public static final String OHOS_BATTERY_TECHNOLOGY
This constant is a keyword used to extract a string variable from Intent.COMMON_EVENT_BATTERY_CHANGED.
The string variable contains the battery technology.
public static final String OHOS_BATTERY_TEMPERATURE
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the battery temperature.
public static final String OHOS_BATTERY_VOLTAGE
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the battery voltage.
public static final String OHOS_CHARGE_COUNTER
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the value of coulometer.
public static final String OHOS_CHARGE_STATE
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the charging state.
public static final String OHOS_CHARGE_TYPE
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the charger type.
public static final String OHOS_CHARGING_CURRENT_MAX
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the maximum charging current of the battery.
public static final String OHOS_CHARGING_VOLTAGE_MAX
This constant is a keyword used to extract an integer variable from
Intent.COMMON_EVENT_BATTERY_CHANGED.
The integer variable contains the maximum voltage of the battery.
public int getCapacity()
public BatteryInfo.BatteryChargeState getChargingStatus()
The battery charging status can be NONE, ENABLE, DISABLE, or FULL.
ENABLE.public BatteryInfo.BatteryHealthState getHealthStatus()
The battery health status can be UNKNOWN, GOOD, OVERHEAT, VOLTAGE,
COLD, or DEAD.
OVERHEAT.public BatteryInfo.BatteryPluggedType getPluggedType()
The charger type can be NONE, AC, USB, or WIRELESS.
AC.public int getVoltage()
3400 mV.public boolean getPresent()
true if the battery is present; returns false otherwise.public String getTechnology()
Li-poly.public int getBatteryTemperature()
26.0 degrees Celsius.public BatteryInfo.BatteryLevel getBatteryLevel()
The battery charge level can be NONE, HIGH, NORMAL, LOW,
or EMERGENCY.