我正在尝试实现此处说明的流程:https://developer.android.com/training/location/receive-location-updates.html
我想使用 requestLocationUpdates() 方法的 PendingIntent 变体,这在上述类(class)中没有解释。
我遇到过两个问题:
- 当我收到 Intent 时,它似乎没有可用的附加功能。此外,没有像 Geofences (getTriggeringGeofences) 或 Activities (extractResult) 这样的辅助函数。我是否需要再次连接到 Location Client 并在 Connect 上获取最后一个位置?在 IntentService 中使用它不会有问题吗?
- 无论我指定什么时间间隔,我只会立即将一个 Intent 发送到我的 IntentService,而不会发送其他 Intent 。这不是完全支持吗?
提前致谢。
最佳答案
文档解释了如何发送 PendingIntent
here .以下是重要的部分:
If the caller supplied a pending intent, then location updates are sent with a key of KEY_LOCATION_CHANGED and a Location value.
这意味着当 PendingIntent
被发送时,应该有一个额外的键 LocationManager.KEY_LOCATION_CHANGED
。这个额外作为 Location
对象。
关于android - LocationClient requestLocationUpdates 与 PendingIntent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16928969/