# How does the Android OS estimate remaining battery time?

Is it known how the Android OS estimates time to failure / remaining battery charge? I am doing a school project about battery estimation on mobile devices but have not been able to find any information about which techniques are used in the industry.

Several people have written articles about how time to failure can be estimated on an Android device, but I have not been able to locate any official information about how it is actual done.

The optimal answer I would like is a link to a scientific article or tech-spec that describe it.

• Where does Android report a time to failure? I've never seen it before. May 19, 2013 at 13:27
• Do you mean the time the device can run on the remaining battery charge, rather than the time to failure? May 19, 2013 at 13:50
• Yes that it what I mean. I had the understanding that it was the proper technical word to use. May 19, 2013 at 13:54
• Have you looked at the source code yet? May 19, 2013 at 15:51
• time to failure = time left on remaining battery charge May 19, 2013 at 21:51

In the API it is described that the battery percentage is calculated by dividing the current level with the maximum level. This can be seen in the quote below.

This leads me to believe that BatteryManager.EXTRA_LEVEL is either measured in Milli amps Hour (mAh) or a value between 0-100. This is a simple approach and not the answer that I hoped to find but it is an answer never the less. Now I just need a official source that states the answer. :)

## Determine the Current Battery Level

In some cases it's also useful to determine the current battery level. You may choose to reduce the rate of your background updates if the battery charge is below a certain level.

You can find the current battery charge by extracting the current battery level and scale from the battery status intent as shown here:

`int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);`

`int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);`

`float batteryPct = level / (float)scale;`