如何根据当前剩余电池电量获取可能完成的通话时间、音乐/视频播放时间、空闲时间的估计量

发布于 2024-11-02 09:04:58 字数 241 浏览 1 评论 0原文

我正在开发令人惊叹的 Android 平台。我正在创建一个处理手机电池电量的应用程序。我正在显示手机的当前电池电量,以及一些其他技术内容。我想获得估计的通话时间、音乐/视频播放时间、空闲时间可能会根据手机当前剩余电量来完成。使用此功能,用户可以知道,如果他的电池电量为 50%,那么他可能可以再进行 2 小时的通话(或)听 1 小时音乐(或)如果手机未动过的话可以持续大约4个小时。通过这种方式,它会对用户有所帮助。请帮助我建议一种方法(或者)是否有可用的 API。?

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.?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

入怼 2024-11-09 09:04:58

不能肯定地说,但我非常怀疑是否有任何 API 可以实现这一点。

我认为唯一可行的方法是收集数据并尝试尽可能接近地估计。您可以尝试测量每个应用程序/使用消耗的电量,也可以尝试测量电池容量。您必须不时调整您的值,因为不是新的电池有时会降低电压等,因此它是一个移动目标。

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.

西瑶 2024-11-09 09:04:58

我认为这是不可能做到的。

正如 @dain 建议的那样,您可以托盘和测量历史数据,并据此进行猜测,但作为各种后台进程(连接强度低意味着大量搜索,无论是否有 wifi、后台数据、新应用程序,等等) )对此有影响,因此根据收集的数据很难准确。

您也许能够针对特定进程(例如呼叫或使用音乐播放器等特定应用程序),并检查它们平均使用多少电量,然后从那里开始。

您使用什么解决方案,我认为由于所有数据的差异,您将从中得到某种平均值,这对于当前情况可能不正确。您可能会逃避每次活动的“最短”与“最长”时间?

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?

一瞬间的火花 2024-11-09 09:04:58

最终意图意图=新意图(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);
启动活动(意图);

这对我有用

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文