【问题标题】:Android Locations: PendingIntent vs. LocationListenerAndroid 位置:PendingIntent 与 LocationListener
【发布时间】:2012-04-01 08:35:39
【问题描述】:

我对何时应该使用 PendingIntent 与 LocationListener 来获取位置感到困惑。如果我有一个始终保持活动状态的服务,可以使用 LocationListeners 吗?

【问题讨论】:

    标签: android service location android-pendingintent locationlistener


    【解决方案1】:

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

    如果组件需要专门更新位置,则不会 周围——比如说,一个 IntentService——我会使用 PendingIntent。你 在这种情况下不能使用 LocationListener,因为里面什么都没有 要监听位置的内存。

    来源:When is advised PendingIntent vs. LocationListener on requestLocationUpdates?

    【讨论】:

    • 我看到了这个,我在我的服务中调用 Looper.loop() 所以它应该还在内存中。我正在寻找使用其中一个或另一个的其他原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多