gpt4 book ai didi

android - 在运行时更改融合位置优先级

转载 作者:行者123 更新时间:2023-11-30 02:11:50 25 4
gpt4 key购买 nike

我有两个意向服务:1. 使用 Fused Location API 在后台接收位置更新。2. 使用 Activity Recognition API 在后台接收 Activity Recognition。

每当我检测到用户站着不动时,我希望能够将融合位置的优先级从 PRIORITY_HIGH_ACCURACY 更改为 PRIORITY_BALANCED_POWER_ACCURACY。

我听说过 removeLocationUpdates() 然后调用 requestLocationUpdates() 但我不能使用它,因为我只在后台运行没有 Activity 的 Intent 服务。

任何帮助都会有所帮助。

最佳答案

您的应用可以同时在多个位置连接到 GoogleApiClient。使用 blockingConnect() 连接到 GoogleApiClient 会容易得多在您的 Activity 识别中 IntentService 这样您就可以调用 requestLocationUpdates()需要时直接使用。

注意 requestLocationUpdates() Javadoc 的注释:

Any previously registered requests that have the same PendingIntent (as defined by equals(Object)) will be replaced by this request.

因此不需要调用 removeLocationUpdates()

关于android - 在运行时更改融合位置优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29992684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com