java Android:制作地理围栏的简单方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12028928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android: Simple way to make a geofence?
提问by thedeepfield
I'm new to Android development and am creating an app that allows a User to create a Geo fence around a specific location for reminders. For example: Making a geofence around a grocery store to remind the user as he enters to pick up Orange Juice.
我是 Android 开发新手,正在创建一个应用程序,允许用户围绕特定位置创建地理围栏以进行提醒。例如:在杂货店周围设置地理围栏以提醒用户进入取橙汁。
Does anyone know of a tutorial that could help in developing something like this?
有谁知道可以帮助开发这样的东西的教程?
回答by Ginger McMurray
AFAIK there are no tutorials for geofencing, but it's pretty simple (assuming you want a circular fence).
AFAIK 没有地理围栏的教程,但它非常简单(假设您想要一个圆形围栏)。
- This tutorialwill tell you how to get the user's location
- Any of theselinks will show you how to calculate the distance between their current location and the centerpoint for their fence
- Calculate their distance from the center at regular intervals. I'd let them set the interval through a settings screen and start with a default around five minutes because anything more than that is a hefty battery drain. Store that distance every time you get it.
- If their last distance compared to their new distance crosses the boundary, perform your action. For instance, I worked on an app that would alert a parent if the child left a friend's house or arrived at school.
回答by Ejmedina
You can use the new GeoFence class released at Google IO 2013:
您可以使用在 Google IO 2013 上发布的新 GeoFence 类:
http://developer.android.com/reference/com/google/android/gms/location/Geofence.html
http://developer.android.com/reference/com/google/android/gms/location/Geofence.html
回答by Jaimoto
I′ve found this simple and working example
我找到了这个简单而有效的例子
http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html
http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html
回答by user3103443
An new API called Proxim.io was recently developed that serves your purpose. The website is www.proxim.io. Here is a quote from the developer documentation:
最近开发了一个名为 Proxim.io 的新 API,可以满足您的目的。该网站是 www.proxim.io。这是开发人员文档中的引用:
Proxim.io is a platform for delivering relevant messages to your application users. Messages that are delivered based on real-time location, topics of interest, and geo-triggers. Messages can be delivered to a device via Push, or can be routed to a software system through an API (Web Events).
Proxim.io 是一个向您的应用程序用户提供相关消息的平台。基于实时位置、感兴趣的主题和地理触发器传递的消息。消息可以通过 Push 传递到设备,也可以通过 API(Web Events)路由到软件系统。