Android: Simple way to make a geofence?

醉酒当歌 提交于 2021-02-17 21:29:56

问题


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.

Does anyone know of a tutorial that could help in developing something like this?


回答1:


AFAIK there are no tutorials for geofencing, but it's pretty simple (assuming you want a circular fence).

  • This tutorial will tell you how to get the user's location
  • Any of these links 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.



回答2:


You can use the new GeoFence class released at Google IO 2013:

http://developer.android.com/reference/com/google/android/gms/location/Geofence.html




回答3:


I´ve found this simple and working example

http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html




回答4:


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



来源:https://stackoverflow.com/questions/12028928/android-simple-way-to-make-a-geofence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!