I'm having trouble trying to access most of the stats from my Android device's battery such as BATTERY_PROPERTY_CAPACITY
, BATTERY_PROPERTY_CHARGE_COUNTER
or BATTERY_PROPERTY_CURRENT_AVERAGE
. These properties are all clearly documented here: http://developer.android.com/reference/android/os/BatteryManager.html
I have the following permission declared on my manifest:
<uses-permission android:name="android.permission.BATTERY_STATS" />
I have a non-null BatteryManager instance:
mBatteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
And whenever I try to retrieve these stats:
double remainingCapacity = mBatteryManager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY);
double batteryCapacityMicroAh = mBatteryManager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER);
double averageCurrentMicroA = mBatteryManager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE);
The results are all 0 for all of those. Always, without fail, 0. I've tried this on an emulator, an actual device, and everything I've thought of has failed to modify my results.
I'd greatly appreciate any help. Ultimately, what I'm trying to do is calculate the time remaining for a device to reach its full charge (while charging). Thanks in advance.