Search code examples
androidbattery

How to obtain the remaining energy from BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER


I'm trying to get the energy consumption of my phone. I'm doing as follows but the result is 0 while I was specting any amount of nanowatts per hour.

    int status2 = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);

What is my problem?


Solution

  • I think BATTERY_PROPERTY_ENERGY_COUNT should be retreived using getLongIntProperty