我有两个意向服务: 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/