# Battery charging time calculation

One of the very useful feature of Android version 5.0 Lollipop is that it shows how much time is left for the charging to be completed. How is the time for the device to get fully charged determined?

To put it bluntly? Lets say you were charging from 0% to 100%. It would work out how long it takes to charge a certain amount (like 1%, for instance. In reality, it's a significantly smaller number than that) and then uses maths to work out how long it takes to get to 100% (so how long it took that 1% x 100). In reality, it is constantly doing this math as you are charging, therefore keeping the time accurate.

Many things can affect how long it takes to charge our percentage, though. A charge via USB is slower than via plug, and playing a game or watching funny cat videos on youtube in 1080p is going to really slow the charging speed.

• Can you support your answer with credible sources? One might want to independently verify your claim. – Firelord Mar 2 '16 at 16:40
• @Firelord tbh, I'm basing it off calculations I done myself, since the internet has no real answer (unless you count app ads) it'd also be the logical approach to calculating it, understandably. – Dan Brown Mar 2 '16 at 23:24
• As per the training document Monitoring the Battery Level and Charging State Determine the Current Battery Level section describes a method, which I presume is implemented in OS and measured periodically (most likely at every 1% change of battery 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;
``````
• Once you know the current level and the time taken to reach that level, I presume time for full charge is stored in ROM (not sure how and where) it is only a matter of extrapolating

Note: This is an educated guess and would welcome inputs