确定 Android 手机与已知点的接近程度,同时节省电量

发布于 2024-09-06 04:45:28 字数 609 浏览 6 评论 0原文

我正在尝试确定 Android 用户是否非常接近预定位置列表。我希望以最少的手机电池消耗来完成此操作。我看到的实现此目的的两种机制是 接近警报请求位置更新。两种方法各有什么优缺点?其中一种对电池的影响会比另一种小吗?无论哪种情况,我都会猜测具体的 使用的位置管理器会对电源使用产生一些影响(现有的 Stack Overflow 答案)

I am trying to determine if an Android user has had a close proximity to a list of predetermined locations. I'd like to do this with the least amount of drain on the phone's battery. The two mechanisms I see for accomplishing this are proximity alerts and requesting location updates. What are the pros and cons of the two methods? Will one have less affect on the battery than the other? In either case I would guess the specific location manager used would have some affect power usage (existing Stack Overflow answer).

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

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

发布评论

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

评论(1

可可 2024-09-13 04:45:28

就电池使用而言,位置更新可能比接近警报便宜。

由于 addProximityAlert 同时使用 NETWORK_PROVIDERGPS_PROVIDER ,您将无法选择要使用的提供商。此外,虽然文档表明它将屏幕关闭时的邻近检查限制为每四分钟一次,但我找不到支持此类功能的代码,而我能找到的基本上是 调用requestLocationUpdates,最小时间间隔提示为1000毫秒。由于建议后台服务使用超过60000毫秒的值,我怀疑它会更便宜以较大的最小时间间隔和 NETWORK_PROVIDER 直接调用 requestLocationUpdates

Location updates are probably less expensive than proximity alerts in terms of battery usage.

Since addProximityAlert uses both NETWORK_PROVIDER and GPS_PROVIDER, you lose the ability to pick which provider you want to use. Additionally, while the documentation suggests that it limits proximity checks to once every four minutes when the screen is off, I can't find the code to support such functionality and what I can find is essentially a call to requestLocationUpdates with a minimum time interval hint of 1000 ms. Since it is recommended that background services use values over 60000 ms, I suspect that it would be less expensive to call requestLocationUpdates directy with a large minimum time interval and NETWORK_PROVIDER.

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