我从BatteryManager
. 这是什么意思?有人能知道吗?
这是我想要的代码:
int health = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
研究区。
根据文档android 使用以下常量。
enum {
BATTERY_STATUS_UNKNOWN = 1,
BATTERY_STATUS_CHARGING = 2,
BATTERY_STATUS_DISCHARGING = 3,
BATTERY_STATUS_NOT_CHARGING = 4,
BATTERY_STATUS_FULL = 5,
};
enum {
BATTERY_HEALTH_UNKNOWN = 1,
BATTERY_HEALTH_GOOD = 2,
BATTERY_HEALTH_OVERHEAT = 3,
BATTERY_HEALTH_DEAD = 4,
BATTERY_HEALTH_OVER_VOLTAGE = 5,
BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6,
BATTERY_HEALTH_COLD = 7,
};
根据我的研究,我没有看到任何“9”值。这个值并不总是来,很少来,但我无法检测到这种情况。