I am looking for a code for estimating/guessing time remaining before the android phone battery is completely discharged. My search results were full of apps available and also the common comment that it's pretty much useless to calculate it. However i need the code. Any help, even a rough snippet, will do for getting started with.
相关问题
- 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
You can not accurately guess that how much time is remaining for battery discharge, because there might be different applications or service consuming battery. thus it might vary.
However you can get battery life with help of broadcast receiver by registering a receiver for action Intent.ACTION_BATTERY_CHANGED. My answer is key only, get information from Android Developers website.
By using the below statement in onReceive() method of BroadcastReceiver with above Intent action, you will get battery level currently available(e.g., 50%, 60%, etc.). But you can't estimate the time remaining, because some apps may consume more power. So i think battery level to time remaining conversion won't give correct result.
I hope it may help you.