简体   繁体   English

Android应用程序中的地理围栏

[英]Geofencing in android app

I am building a check in and check out application currently. 我正在构建一个签入并签出应用程序。 User should be able to check in with the current location and when he goes 50 meters away from the current location he should be checked out. 用户应该能够在当前位置签到,并且当他离开当前位置50米时,应该将其签出。

Can this be implemented using Geo Fencing for android? 可以使用Geo Fencing for Android来实现吗?

I came across this piece of code but do not know how to use: 我遇到了这段代码,但不知道如何使用:

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);

I would really appreciate if the correct way to use geo fencing could be given. 如果可以给出使用地理围栏的正确方法,我将不胜感激。

You can implement this using geofencing. 您可以使用地理围栏来实现。

The sample code you posted has to do with persisting a Geofence object. 您发布的示例代码与持久化Geofence对象有关。

If you want to know how to register a Geofence, check out this presentation on using the geofencing APIs and these android docs . 如果您想知道如何注册Geofence,请查看有关使用geofencing API和这些android docs的 演示 The prezi has some sample code that boils down the use of the APIs to 10 lines of code. prezi包含一些示例代码,这些示例将API的使用归结为10行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM