Android Development: How do I predict expected battery life based on current battery level?

StackOverflow https://stackoverflow.com/questions/19085750

  •  29-06-2022
  •  | 
  •  

문제

I have a requirement of predicting the battery duration from within my android app. I have the cpu data, memory information and current battery level. I have also plotted graphs of these values over the past few minutes using the AndroidPlot library. Using these data (or anything else), what is the best way of predicting the time before the battery runs out on the device?

도움이 되었습니까?

해결책

You can always try to predict something but the question would be how accurate the prediction is?

Based on the Data (cpu, memory and battery level) you can create a database and keep track of every application battery consumption. And, using of those information you can always generate a prediction. You can use ActivityManager to get list of running process.

Second, Read this interesting Article thoroughly and use WiFiManager to collect wifi state, wireless radios are a big battery drainer.For more accuracy you can even check Bluetooth radio status. Make sure to combine all these with ConnectivityManager.

Third, use power manager to check display staus.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
 boolean isScreenOn = pm.isScreenOn();

Combine all these together to make a better prediction.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top