1

I want to periodically log the battery level in percent. I am only concerned with obtaining the actual battery level, not with graphing it. I have found the APIs to register an intent to receive Intent.ACTION_BATTERY_CHANGED, using BatteryManager.EXTRA_LEVEL and BatteryManager.EXTRA_SCALE.

However, my problem is, this only gives me increments of 10%, which is not fine-grained enough. I have the SystemPanel App from the Android Market, and it plots percentage versus time on a much finer scale, so I know it is possible, but in all my searching nobody seems to address how I can get this higher resolution.

This question appears to point to another project that accomplishes this, but it is not obvious how it accomplishes this: Creating a graph similar to Battery usage in Gingerbread

Community
  • 1
  • 1
Michael
  • 9,060
  • 14
  • 61
  • 123

3 Answers3

1

Although the battery may not report percentages finer than 10%, it does report voltage in 1mV increments. Using this, it is possible to watching the mV level at which each 10% drop is achieved and interpolate the actual percentage with that.

Michael
  • 9,060
  • 14
  • 61
  • 123
0

Please refer to this question, which was asked previously here on Stack Overflow. The second answer covers it well with code examples:

Android Battery in SDK

Community
  • 1
  • 1
Michell Bak
  • 13,182
  • 11
  • 64
  • 121
0

You should be careful of fragmentation, the devices are different, and some devices (like Samsung Galaxy 5) register battery changes for every 1%, but others (like factory-state Motorola Milestone) register battery changes for every 10% if it is not changed by a mod or rom. I think you are using the right method to get this, but check your device.

Gustavo Maciel
  • 652
  • 7
  • 20