当requestLocationUpdates建议PendingIntent与LocationListener的? [英] When is advised PendingIntent vs. LocationListener on requestLocationUpdates?
问题描述
您可以通过两种方式认购requestLocationUpdates
you can subscribe to requestLocationUpdates via two ways
- 在一个接一个specifing PendingIntent
- 另一种是用LocationListener的
当被告知之一,当其它?
When is advised the one and when the other?
推荐答案
如果该组件需要的位置更新只需要更新组件时左右 - 也就是说,一个活动 - 我会使用 LocationListener的
办法。
If the component needing location updates only needs updates when the component is around -- say, an activity -- I'd use the LocationListener
approach.
如果该组件需要专门的位置更新不会左右 - 也就是说,一个 IntentService
- 我会使用 PendingIntent
。你不能使用 LocationListener的
在这种情况下,由于没有什么内存被监听的位置。
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.
这篇关于当requestLocationUpdates建议PendingIntent与LocationListener的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!