【问题标题】:When is advised PendingIntent vs. LocationListener on requestLocationUpdates?在 requestLocationUpdates 上何时建议 PendingIntent 与 LocationListener?
【发布时间】:2010-06-25 21:25:45
【问题描述】:

您可以通过两种方式订阅 requestLocationUpdates

  • 通过指定 PendingIntent 实现
  • 另一个是使用 LocationListener

什么时候通知一个,什么时候通知另一个?

【问题讨论】:

    标签: android geolocation android-pendingintent


    【解决方案1】:

    如果需要位置更新的组件仅在组件存在时才需要更新——比如说,一个活动——我会使用LocationListener 方法。

    如果需要特别更新位置的组件不会出现——比如IntentService——我会使用PendingIntent。在这种情况下,您不能使用 LocationListener,因为内存中没有任何内容可以监听位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-01
      • 2013-05-21
      • 2015-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多