如何在繁重的服务中最大限度地减少电池消耗

发布于 2024-08-16 16:35:10 字数 331 浏览 7 评论 0原文

我想创建一项服务,以便在发生某些“热点情况”时执行某些操作,“热点情况”的意思如下:

  • GPS/小区坐标位于已知区域
  • 检测到已知蓝牙设备
  • 已知 Wi-Fi 网络检测到的
  • 天气信息已发生变化,
  • 检测到的设备的加速度发生了相当大的变化:例如。从步行到驾车出行。

正如我们所看到的,这些任务很“繁重”,并且会频繁运行——比如 15 分钟,但有时甚至更长——当我必须检测设备的加速度时。

我的问题是:这项服务会严重耗尽电池电量吗?

如果是这样,您有什么建议可以最大限度地减少上述任务的电池消耗?

I would like create a service to do something when some "hot situation" occurs, and by "hot situation" I mean the following:

  • the GPS/cell coordinates are in a known zone
  • a known Bluetooth device is detected
  • a known Wi-Fi network is detected
  • weather info has changed
  • considerable change in acceleration of device detected: eg. from walking to travel by car.

As one can see, these tasks are "heavy" and will be run frequently – say, 15 minutes, but sometimes even more – when I have to detect the acceleration of the device.

The question I have is this: will this service drain the battery heavily?

If so, what recommendations do you have to minimize battery drain from the tasks described above?

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

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

发布评论

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

评论(2

梦境 2024-08-23 16:35:10

您可能对此感兴趣:

电池寿命编码

This might be of interest to you:

Coding for battery life

累赘 2024-08-23 16:35:10

GPS 是最耗电的——如果一直开着它,电池使用时间可能会减少一半。无线连接也是一个很大的消耗者。如果您的应用程序通过蜂窝网络工作,那么如果手机连接到 3G,那么它的消耗速度可能与无线连接一样快(甚至可能更快)...

我建议重新考虑您的服务的使用。也许将其制作成一个应用程序,并让用户在认为处于“热门情况”时明确打开它。将其保留为服务,用户可能会开始将您的应用程序视为某种故障程序,这将严重损害您的下载/销售。

此外,要跟踪应用程序的电池使用情况,您可以访问 Android 偏好设置中的“电池使用情况面板”。

GPS is the top battery drainer - by having it on all the time, the battery duration will probably be cut down to half. Wireless connection is also quite a big drainer. If your app is working via the cell network, then if the phone is connecting to 3G then that probably drains as quickly as wireless connection anyway (maybe even more)...

I would suggest rethinking the usage of your service. Maybe make it into an app and have the user explicitly turning it on when he thinks to be in a "hot situation". Leave it as a service and the user might start thinking of your app as some sort of malfunctioning program and that will hurt severely your downloads/sales.

Also, to keep track of your apps battery usage, you can visit the "Battery usage panel" that lives inside Android preferences.

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