com.google.android.gms.location.LocationListener和android.location.LocationListener之间的区别是什么?

时间:2016-06-22 07:22:44

标签: android location google-location-services

我想问一下这两个库中的onLocaticonChange方法。我可以从android.location.LocationListener中捕获位置,但是当我决定使用google.android.gms.location.LocationListener的onLocationChanged方法时,location参数返回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' 

我不知道什么是不同的。任何人都能描述我吗? 感谢。

1 个答案:

答案 0 :(得分:1)

<强> com.google.android.gms.location.LocationListener

这是谷歌播放服务。基本上谷歌播放服务将寻找自己使用的持续位置更新。您将再次向用户发送相同的位置更新。

<强> android.location.LocationListener

此基本位置监听器是您根据自己的使用情况设置的,并且位置uapdtes将立即发送给您作为约束设置(如电池,电源,位置提供商,准确性)

差异

  1. com.google.android.gms.location.LocationListener将需要谷歌 玩服务设置,android.location.LocationListener非常 基本剂量不需要游戏服务依赖

  2. 大多数情况下com.google.android.gms.location.LocationListener会更快,并且会在已经设置并且位置已经可用时启动快速提升。