gpt4 book ai didi

android - com.google.android.gms.location.LocationListener 和 android.location.LocationListener 之间有什么区别?

转载 作者:行者123 更新时间:2023-11-30 01:15:07 26 4
gpt4 key购买 nike

我想问一下这两个库中的 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.LocationListener

这与 google play 服务一起提供。基本上,Google Play 服务会寻找持续的位置更新以供自己使用。您将成为另一位用户,相同的位置更新将发送给您。

android.location.LocationListener

您为您的使用设置的这个基本位置监听器,一旦为您设置位置提供程序作为约束集(如电池、电源、位置提供程序、准确性),位置 uapdtes 将发送给您

差异

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

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

关于android - com.google.android.gms.location.LocationListener 和 android.location.LocationListener 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37961157/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com