我很困惑何时应该使用 PendingIntent 和 LocationListener 来获取位置。如果我有一个始终保持 Activity 状态的服务,可以使用 LocationListeners 吗?
最佳答案
If the component needing location updates only needs updates when the component is around -- say, an activity -- I'd use the LocationListener approach.
If the component needing location updates specifically will not be around -- say, an IntentService -- I'd use the PendingIntent. You can't use the LocationListener in this case, since there is nothing in memory to be listening for locations.
来源:When is advised PendingIntent vs. LocationListener on requestLocationUpdates?
关于Android 位置 : PendingIntent vs. LocationListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9726457/