Geofence on current user location - android

I am currently studying a possible project on Android and iPhone.
I need to know if geofences could help me, or if another method should be used.
I think the geofence are not used in this way but I ask anyway.
Is it possible to place a geofence on the current user location (even if it moves) and sending messages when other people come on the geofence position (even they are 100 000) ?
Thank you very much in advance for your answers.

It's do-able but you will be lagging a lot...you will have to get a strong server to get all the positions of the users at a given time and place a listener on each user location s.t. in case his geolocation gets into some geofence every listener should inform its listenee (which will probable be the user class), so far should be good BUT hypothetically 1 user can get into millions other geofences (indicating your start-up is running quite good...) which will require the server to send millions of alert, now think on a million users moving - that means that even if you send just their location you can end up moving a couple of tera-bytes in a second to the server and from it plus requiring it to make more than trillions actions (probabley push notifications?) per second...

It depends on many variables as: radius of your geofences, quantity of users, etc. Notice, that in normal life you never approach 100000 people at one time, well, maybe at the football game. I think nothing is impossible, but a lot of factors need to be reviewed.

Related

How to know when 2 persons cross in the street ? (Geofences...)

I want to create an Android app with a simple concept : if 2 persons who have downloaded my app are crossing in the street, I want to send them a notification (immediately).
I started to use the geofences concept, but I don't know if it is the most appropriate. So my questions are the following :
Using the geofences (every user have his own geofence, so you are notified when entering an other user geofence), how can I make the geofence following the user when he is moving ? (with enough precision but without too much power consumption)
Is there another concept that is more appropriate to my problem than the geofences ?
Thank you :)
Since both persons are in movement, I think you need to call the position frequently and therefore it doesn't make sense anymore to use Geofences. Instead you would calculate the difference between them and push a notification from server when a certain threshold is reached.
if you want use geofences with server side will be more easy for app(in android u only can register 100 geofences) you can check in server the nearest users from you.
but if you need check user very close to you i think is better use Bluetooth, you can emulate ibeacons and the app can register beacon region and monitoring it. dont care gps signal and battery drain. In android you can use altbeacon open source lib for ibeacons/eddystone.
contact me if need more help and sorry my english ;)

Library to update more than 100 geofence

I know that there is a technique to update more than 100 geofence to google api client. But I want a complete solution to add more than 100 geofence or any library to achieve it. I already done my project using google api client. But there is limitation off 100 geofence only.
Is there any library or any other technique to update more than 100 geofence?
And all these process should run in background. I mean even after application process is killed, this should run in background. Is it possible?
Thanks in advance.
The issue with having more than 100 geofences is that depending on how close they are in proximity to the user and how many geofences you actually have, it can become a serious battery drain due to constant location polling. I'm not sure how you plan to implement your geofences, but I would suggest you look into loading only geofences within your immediate and surrounding area, storing the rest into a database, and loading/unloading depending on your current location and distance from the edge of the geofences. Bing came up with this nice tiling system that may come in handy for you.

Android: Right approach for sensing the distance between current location and some point of interest?

I have a question regarding my programming approach for android - whether it's efficient or not. Just to give you an idea what I try to accomplish:
There are multiple points of interests on a map. If the user gets nearer to a PIT, a notification about the distance shall appear. There are let's say 3 notifications: At a distance of 1 mile, 0.5 miles and 0.1 mile. When the user is more or less exactly at the PIT, no more notifications are shown. The user is supposed to drive a car or another vehicle.
I'm currently using Geofences to detect whether the user has entered a radius of 1 mile. If so, I check the distance of his current location to the PIT. If it's about 0.5 or 0.1 miles away, a notification is fired. Therefore, I check the current location frequently (right now every 10 seconds). If the user is like at the PIT or rather very close, the Geofence is exited and done.
The code is working fine and this approach is the first thing that came to my mind while reading the Android Developer's tutorials etc. But is there another approach that is MORE EFFICIENT?
Although this is (currently) meeting my needs, I have two major concerns:
It seems to drain the battery quite a lot. Since the user is most likely to be in a car where he can charge his phone during usage, this might be less of a problem.
I read the number of PITs from a file on the SD card. In my example I have just a few PITs. But the user is able to modify the source data so that he can add as many as he wants to. Google says that only 100 active Geofences are supported per user. But what if my user has more than 100 PITs? Since I'm using a Geofence to sense whether I have to fire the first notification or not - this is a severe problem. So is there an alternative?
I have a few suggestions :
1) To lower the amount of gps fixes, you could calculate a sleep time. The idea is to do frequent gps fixes when near a 'border' and few when far away. This could be further enhanced by taking the speed parameter returned by the GPS into account.
If for instance the user is 20 miles from the nearest border while driving 20mph, you can easily wait 30 minutes before turning on the gps again, just to give a simple example.
2) I have run in to the same problem. My solution was simply to select only the POI's within X miles. This way ensuring never to risk hitting the limit of 100. When the user has moved (X-1) miles from his initial position, the geofences are rebuild using the new location.
If you think there is a high risk of having such a high density of points that the above strategy still might fall, I would consider making your own proximity checking entirely based on gps instead of geofences.

GeoFence or distance calculation... what's the difference?

I read in the documentation that I can setup geofencing so I know when the user entered/left the geofenced area.
However, I was wondering, can't I get the same behaviour by just taking my current location (ona regular location update) and check the distance with the center of the intended geofence. If it is less than a certain radius then I am within that area.
Wouldn't that have the same effect (infact way less code than geofence)?
Thank you
I believe the advantage of a geofence as opposed to what you describe, is that geofences are objects that come with a lot of extra support in Google Play Services. Using geofences allows multiple different Activities or even Applications to get notifications/callbacks from a single (or set of) geofence objects created elsewhere. These callbacks will happen automatically even if you are in another application because Google Play Services can monitor location in the background without you writing additional code in your Activity, and they can expire on their own. Doing this would be more difficult if you were to roll your own distance calculations as you would have to set it up your own Service framework.
From this answer by CommonsWare:
Geofences are designed to work even without your application running.
However, if your goal is only to check whether you are a certain distance from a geographical point (without caring about what happens when the user goes to check their email or puts their phone back in their pocket), then what you describe might be easier.

Notify when user is in my location in Android

I am looking for an easy way to check if a user is at my location (50m) radius if notify me.
Right now I have a service running every two minutes getting position of each user comparing it and then notifying if user in same location.
Can this be done using promixityalert: http://goo.gl/9I857T?
Thanks!
Instead ProximityAlert I would use Geofences.
http://developer.android.com/training/location/geofencing.html
Is newer and does a more effective use of the battery
In your case, you can have a service that sends to the other device the current location every X minutes, so it can update the Geofence. The problem that I see is that there would be a lot of calls, spending battery and the data plan.
A good approach is to use the Location Services API, you can detect if a user is standing or moving.
http://developer.android.com/training/location/activity-recognition.html
Using this and sending new locations only when the user is moving you will be able to reduce the amount of calls.
Parse is another option as #thepace mention. It is easy to use and whit it would be easy to implement what you are trying to do, but is not free :(
Hope it helps.
Issue: Check if any user (multiple and variable location) is within specific radius of my current location(variable).
Solution:
1. Parse.com
a) Ensure every user has their location updated in Parse DB including yours.
https://parse.com/tutorials/anywall-android
b) Use push notificaitons: https://parse.com/docs/push_guide#setup/Android
1> Create a channel wherein only you are subscribed.
2> Create your installation query and send notification to it to the channel subscribed.

Categories

Resources