【问题标题】:Geofencing in android appAndroid应用程序中的地理围栏
【发布时间】:2014-04-22 11:45:58
【问题描述】:

我目前正在构建一个签入和签出应用程序。用户应该能够在当前位置签到,当他离开当前位置 50 米时,他应该被签出。

这可以使用 android 的地理围栏实现吗?

遇到了这段代码,但不知道怎么用:

SimpleGeofence mUIGeofence1 = new SimpleGeofence("1",
               Double.valueOf(mLatitude1.getText().toString()),
               Double.valueOf(mLongitude1.getText().toString()),
               Float.valueOf(mRadius1.getText().toString()),
               GEOFENCE_EXPIRATION_TIME,
               // This geofence records only entry transitions
               Geofence.GEOFENCE_TRANSITION_ENTER);
mGeofenceStorage.setGeofence("1", mUIGeofence1);

如果能给出使用地理围栏的正确方法,我将不胜感激。

【问题讨论】:

    标签: android location geofencing android-geofence


    【解决方案1】:

    您可以使用地理围栏来实现这一点。

    您发布的示例代码与持久化 Geofence 对象有关。

    如果您想知道如何注册Geofence,,请查看this presentation,了解如何使用地理围栏 API 和these android docs。 prezi 有一些示例代码,将 API 的使用归结为 10 行代码。

    【讨论】:

      猜你喜欢
      • 2014-07-25
      • 1970-01-01
      • 1970-01-01
      • 2013-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-17
      相关资源
      最近更新 更多