【问题标题】:Get my current position that triggered a Geofence event获取触发地理围栏事件的当前位置
【发布时间】:2014-05-19 07:36:21
【问题描述】:

我正在使用 Android Location API 来注册地理围栏。

是否可以在 IntentService 的 onHandleIntent() 方法或 onReceive() 方法(使用 BroadcastReceiver 时)中获取触发 Geofence-Exit 事件的用户位置?

我目前的方法是使用LocationManager.getLastKnownLocation(String provider),但我不确定这是否可靠,因为我必须指定一个提供商,而且我不知道我的地理围栏位置基于哪个提供商。

onHandleIntent(Intent int)onReceive(Intent intent) 中收到的 Intent 也不包含任何有用的位置数据。

长话短说:

是否有一种安全/可靠的方式来获取在 Android 中触发地理围栏事件的位置?

【问题讨论】:

    标签: broadcastreceiver intentservice android-geofence


    【解决方案1】:

    你可以使用

    locationClient.getLastLocation();
    

    此功能不需要提供者。这可能是获得导致退出的位置的最佳方式

    【讨论】:

      猜你喜欢
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 2015-11-07
      • 2020-03-02
      相关资源
      最近更新 更多