【问题标题】:How I can get the location of the device if the GPS is off?如果 GPS 关闭,我如何获取设备的位置?
【发布时间】:2014-01-23 19:30:41
【问题描述】:

我想获取设备的纬度和经度,如果 GPS 关闭,希望可以是精确位置

【问题讨论】:

  • 如果 GPS 关闭,您是否可以获取位置
  • @AnjaliTripathi 是的,你可以得到它,但不是当前位置。尝试使用 Google 服务的“最后已知位置”(developer.android.com/training/location/retrieve-current.html)
  • @zhelon 我使用了这种方法,但如果我的 GPS 关闭,我会得到空值
  • @AnjaliTripathi 抱歉,我不记得我是如何修复它的

标签: android gps android-location


【解决方案1】:

您应该使用新的LocationClient,它是 Google Play 服务Location API 的一部分。它使用一个融合的提供者,该提供者会自动确定当时可用的最佳提供者。它还使用其他传感器来获得更准确的位置。

【讨论】:

    【解决方案2】:

    您可以通过三种技术获取您的位置,每一种都称为 Provider,每一种都有一些优点和缺点,并且使用您并不关心它 Google play 服务会为您提供,但您需要充分了解这一点,三种方式是

    来自 GPS、网络、SIM(带 SIM 卡的移动设备)

    这里有一些技术的实现 http://developer.android.com/guide/topics/location/strategies.html

    【讨论】:

      猜你喜欢
      • 2015-11-02
      • 2022-01-02
      • 1970-01-01
      • 2019-01-22
      • 2017-07-28
      • 1970-01-01
      • 2013-02-28
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多