Android: Simple way to make a geofence?
Asked Answered
A

2

15

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?

Array answered 19/8, 2012 at 18:31 Comment(1)
https://mcmap.net/q/825988/-location-alarm-for-android might be the feature you need.Halberd
H
8

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.
Halflight answered 17/9, 2012 at 17:43 Comment(2)
is it a good idea to have it checking on timely manner (battery issues)? What if the app is 'backgrounded' or even not running. How would you do a push notification to the user in those scenarios?Balkh
It's definitely a battery drain, but when you register for updates via the LocationManager you have to specify a minimum time between updates. You could make that time be incredibly large and instead rely on the minimum distance between updates parameter, but you're not guaranteed a timely response that way. If your app is a background service you shouldn't have problems with it not being active unless the user's phone is experiencing severe processor drag. In any case, you can always trigger a notification via NotificationManager if that's what you're wanting to do.Halflight
J
0

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

Jaggery answered 15/12, 2013 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.