当requestLocationUpdates建议PendingIntent与LocationListener的? [英] When is advised PendingIntent vs. LocationListener on requestLocationUpdates?

查看:422
本文介绍了当requestLocationUpdates建议PendingIntent与LocationListener的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以通过两种方式认购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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆