When is advised PendingIntent vs. LocationListener on requestLocationUpdates?

谁都会走 提交于 2019-12-21 05:23:13

问题


you can subscribe to requestLocationUpdates via two ways

  • one by specifing a PendingIntent
  • the other is by using a LocationListener

When is advised the one and when the other?


回答1:


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.



来源:https://stackoverflow.com/questions/3121557/when-is-advised-pendingintent-vs-locationlistener-on-requestlocationupdates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!