android - LocationClient requestLocationUpdates 与 PendingIntent

标签 android android-intent location android-pendingintent intentservice

我正在尝试实现此处说明的流程: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/

相关文章:

java - Android:根据 ListView 中的项目数显示/隐藏菜单项

android - 内部使用 intent.getextras()

android - 在 android 的谷歌地图上每 10 秒绘制一条折线

android - Android SDK 的推荐 .zshrc 设置

java - Android XML 解析器显示重复数据

android - 我在使用 webintent 时总是出错

android - 超时定位

ios - UNLocationNotificationTrigger- 在模拟器中不工作

android - 为什么当我尝试创建一个新的 android xml 文件时 eclipses 崩溃

java - Intent 构造函数中的 uri 参数究竟是什么?