我很困惑何时应该使用PendingIntent和LocationListener来获取位置。如果我有一个始终保持活动的服务,是否可以使用LocationListeners?
答案 0 :(得分:3)
如果需要位置更新的组件仅在组件到达时需要更新 - 比如活动 - 我会使用 LocationListener方法。
如果具体需要位置更新的组件不会 周围 - 比方说,一个IntentService - 我会使用PendingIntent。您 在这种情况下,不能使用LocationListener,因为没有任何内容 要监听位置的记忆。
来源:When is advised PendingIntent vs. LocationListener on requestLocationUpdates?