Is it possible to calculate remaining battery time in hours and minutes? Also, would it be able to calculate this time depending on if I'm using a certain app? Is it even possible to get such information? If you could please give me advice on how to do that, I'd be very thankful.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Estimating the remaining battery life is based on analytics. As the other people said you have to listen for battery level changes and in addition you have to keep track of them. After some time you will have enough data to calculate what is the average time the battery lasts. In addition you know when the battery drains fast and when drains slow so you can improve your estimation based on this. Also you will know in what time the user charges the devices. There are a lot of events that can be tracked and using the battery level. In addition you can also track when the screen is on or off. The algorithm of calculating the remaining battery life depends on you :)
I hope this explains (at least a bit) the idea of the estimation the battery life.
I don't know the code, but I can help you the logic/formula for this question:
total capacity per speed of the usage
.Oddly enough, for some battery app developers know the code, such as DU Battery Saver.
You can use BatteryManager library to checkout the battery status with EXTRA_LEVEL:
Unfortunately, you can get the remaining time only with approximation because some apps may consume more power.
Cheers