How to get an estimated amount of talktime,music/video playback time, idletime that could be possibly done based on the current level of battery left

妖精的绣舞 提交于 2019-12-12 14:20:09

问题


I am working on the amazing android platform. I am creating an app which deals with the phone's battery level.I am showing the current battery level of the phone, along with few other technical things.I wanted to get an estimated amount of talktime,music/video playback time, idletime that could be possibly done based on the current level of battery left on the phone.Using this the user can get an idea that if his battery level is at 50% then possibly he can do another 2 hours of call talk (or) listen to 1 hour of music (or) if the phone is untouched then it would last for some 4 hours. In this way it would help the user.Please help me in suggesting an approach (or) is there any API available for this.?


回答1:


Can't say for sure, but I highly doubt there would be any API for this.

I think the only workable approach is for you to collect data and try to estimate as close as possible. You can try to measure how much power each app / usage draws and also try to measure battery capacity. You'd have to tweak your values from time to time as batteries which are not new sometimes drop their voltage, etc so it's a moving target.




回答2:


I think this is impossible to do.

As @dain suggests you could tray and measure historical data and make a guesstimation based on that, but as all sorts of background processes (connection strength low means lot of searching, wifi or not, data in the background, new applications, you name it) have influence on this, so it's hard to be accurate based on the collected data.

You might be able to target specific processes (like calling, or using a specific app like a music player), and check how much power they use on average, and go from there.

What sollution you use, I think because of the difference in all the data you will get some sort of mean out of it that would probably not be correct for the current situation. You might get away with a "minimum" vs "maximum" time per activity?




回答3:


final Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.fuelgauge.PowerUsageSummary");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity( intent);

this works for me



来源:https://stackoverflow.com/questions/5714487/how-to-get-an-estimated-amount-of-talktime-music-video-playback-time-idletime-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!