Search code examples
androidbatterymanager

Units of android EXTRA_SCALE and LEVEL in battery manager


At the beginning I thought that EXTRA_LEVEL would return a percentage but I've seen in the API that to get the percentage I have to do EXTRA_LEVEL / EXTRA_SCALE

So now, I wonder, in which units are those pararameters? Are they mA? Thanks!


Solution

  • The EXTRA_SCALE value is (almost?) always set to 100. EXTRA_LEVEL does not contain a value in mA but the level from 0 to EXTRA_SCALE. Thus, assuming that EXTRA_SCALE is always 100, EXTRA_LEVEL would in fact contain the percentage. However, by computing the division you get the relative battery level as a fraction even if EXTRA_SCALE had a different value than 100.