【问题标题】:what is the differents between com.google.android.gms.location.LocationListener and android.location.LocationListener?com.google.android.gms.location.LocationListener 和 android.location.LocationListener 有什么区别?
【发布时间】:2016-06-22 07:22:43
【问题描述】:

我想问一下这两个库中的 onLocaticonChange 方法。我可以从 android.location.LocationListener 捕获位置,但是当我决定使用 google.android.gms.location.LocationListener 的 onLocationChanged 方法时,位置参数返回 null。这是我的 build.gradle 文件:

compile 'com.google.android.gms:play-services-maps:9.0.1'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'com.google.android.gms:play-services-ads:9.0.1'
compile 'com.google.android.gms:play-services-auth:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.1' 

我不知道有什么不同。任何人都可以描述我吗? 谢谢。

【问题讨论】:

  • 我可能是错的,但 com.google.android.gms.location 会为您提供来自谷歌地图的位置,该位置接近准确需要互联网,因此当您的位置发生变化时,它可能会被使用And android.location将根据最后访问的移动信号塔提供位置,因此当您的网络发生变化时,它会使用
  • 我为此创建了一个库并使用这两个库,但我可以从 android.location.LocationListener 中捕获位置。另一个只是为 FusedLocationApi.getLastLocation 工作。感谢您的回复很有帮助:) @VishalMokal

标签: android location google-location-services


【解决方案1】:

com.google.android.gms.location.LocationListener

这带有 google play 服务。基本上谷歌播放服务将寻找持续的位置更新供自己使用。您将成为另一位用户,相同的位置更新将发送给您。

android.location.LocationListener

您为使用而设置的基本位置侦听器,一旦为您设置了位置提供者作为约束集(如电池、电源、位置提供者、准确性),位置 uapdtes 就会发送给您

区别

  1. com.google.android.gms.location.LocationListener 将需要 google 播放服务设置好,android.location.LocationListener 很 基本剂量不需要播放服务依赖

  2. 大多数时候 com.google.android.gms.location.LocationListener 更快,并且会启动快速更新,因为它已经设置并且位置已经可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-02
    • 2011-12-12
    • 2010-09-16
    • 2012-03-14
    • 2012-02-06
    • 2011-02-25
    • 2011-11-22
    • 2015-03-26
    相关资源
    最近更新 更多