Skip to content Skip to sidebar Skip to footer

Batterymanager Health Values

I was wondering about the value that I get from the BatteryManager when I want to have the health. I get a '2'. What does it mean? Can anyone give me all the values I can get and

Solution 1:

Take a look at the documentation on Battery Manager.

You'll be able to see what these constant values mean. For example, the value 2 that you get corresponds to BATTERY_HEALTH_GOOD. You can check that here: Link.

In your activity, you can check your integer variable health against these values like:

if (health == BatteryManager.BATTERY_HEALTH_GOOD) {
    //do something, update a textview, show a Toast
} elseif (health == BatteryManager.BATTERY_HEALTH_OVERHEAT) {
    //do something else, show a warning
} else if. . . . // check for however many valuesor check for all

This way, you won't need to consider the actual value(numerical value) that health variable holds.

Post a Comment for "Batterymanager Health Values"