Search code examples
androidbattery

How to calculate the android battery use time


Now I need to do a calculation android battery time application,But I am in android API inside can only get the current voltage, state, quantity, temperature,And now I want to calculating the current electricity can use long time.For example: I now have 50% of the electricity, 3800 mv voltage, full of to 100% need how long, full of later can use how long,And such as: I opened the wifi, the current power and how long can be used. These how to calculation is better!


Solution

  • That's really not possible, unless you have very good empirical data on the power requirements of each module of your device. But even then, it's largely guess-work.

    Cellular standby current requirements depend on the signal strength -- the stronger the signal from the tower, the less power the device uses to transmit acknowledgements.

    This is similar for wifi as well. Even the beacon frequency of the wifi access point (and how many other access points are on the same and neighboring channels) has a direct influence on the standby current, and thus the battery life.

    And once you have user-interaction, all bets are off: As soon as that big, power-hungry display lights up, your battery is discharging at breakneck speeds.

    The only thing you could track, if you wanted, is to capture the charging state broadcast when the charger is disconnected, and then monitor the battery percentage decrease over time. This you could then extrapolate. For example, if the charger was disconnected 5 minutes ago, and the battery went from 100% to 99%, you could figure that the battery now has 99x5 min, or 495 minutes left, under ideal circumstances.