Notify when user is in my location in Android - 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.

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

Discarding a message, before it gets displayed to the user?

Im trying to develop an Android messenger application where a message is sent by user 1 to everyone using the app, the message contains the GPS location of user 1. Is it possible to determine the distance between user 1 and the user 2 and based on that either choose to display or discard the message. How do I go about it? Cloud you point out considerations that I might have missed out?
Another method I believe is possible is to periodically update a server with every users GPS location and then let the server decide who gets the message, but I would not like to use this method as it would be a privacy issue. No one would want their whereabouts being tracked by a server all day. Is there another solution to this?
You can use the haversine formula to determine the distance between two locations. Here is a link that provides the formula in various languages.
http://www.movable-type.co.uk/scripts/latlong.html
One way of doing this is to store the most recent location of a phone on the server in the database. You can then query the database (using a stored procedure) to determine who your closest neighbors (phones) are by setting a radius. For instance, show me all the phones within 500 meters.
Here is an example of how to do this:
http://www.movable-type.co.uk/scripts/latlong-db.html

How to find ios phone users that are within 1 mile of me - without polling every user?

We are working on an app with the following requirements:
Users will have a Friends list (small subset of users)
User will need to know when a 'Friend' is close to them (aprox < 1 mile)
We are currently doing the following:
Each User posts there location to a central DB every 15 mins
User searches DB for Users that are friends & distance < 1 mile
The issue is - thats alot of Location Polling & many users don't like constant polling.
Is there a better way?
The current approach looks perfect here.
Other wise you need to manually trigger user that he/she needs to update their current location.
What you can do if some one wants to know near by friends list:
Make a web service call that user from X group is trigger an event for location updates.
Send a push notification to all other user from group X that update current location / sync current location with online database.
Filter users from latest current location details.
Pros:
You will get real time location updates (fraction of mins)
Only limited users (group of users) needs to update their location
Do not need to constantly location polling
Cons:
Push notification required
User have to manually sync their location, if some one does not sync it will be not effective.
However there are many things which needs to be consider for scenario above, I have roughy listed which strikes in a mind first.
Again it still depends on application architecture and server configuration to manage every alternatives.
"User searches DB for Users that are friends & distance < 1 mile"
Maybe it will be better to server side make that job?
The clients only ask server - 'Any friends around me?'
Also you can try to deliver that info by push notifications. But notification can arrive with delay (or may not delivered at all).
I'm not sure about Android but for iOS you can configure your app to update location more conservatively using significant-change location as referred to in the Apple's Docs. Then when your user is actively using the app (or some other business logic such as close to an active friend) temporarily change to the standard location service for greater accuracy and more frequent polling.
By using the significant change method you could just update the server occasionally rather than every 15 minutes and sometimes more frequently if a person is on the move and then alter your search predicate to reflect these update changes.
The part that seemed most relevant was:
The significant-change location service delivers updates only when there has been a significant change in the device’s location, such as 500 meters or more.

Geofence on current user location

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.

Is there anything similar to c2dm, to get know user position or I need to implement service and inform server periodically?

I need to inform user with location specific data from server when they are on some location. Is there anything similar to c2dm, to get know user position or I need to implement service and inform server periodically ?
you can set a variable true or false.Use c2dm to activate this variable from server side...when this variable change his state then it means that server want your position, and you send it.
I think you're asking if there is a service which has all user positions saved and up-to-date. That is not the case (at least nothing like that officially exists). You will need to get the data from the gps sensor and then compare it periodically with the server data.
You wouldn't generally use C2DM to request data from the user.
It sounds like when you go near a location, the server needs to supply the client with data about that location?
If so, you could use C2DM to give the user a list of locations of interest. Then when the client goes near it, they request the data from the server.
Depending on how often these locations change (and the importance if they do..) determine if C2DM is worth implementing.
If the updates are only important to the user when using the app, request the list of locations on app start up / periodically when the app is in use / refresh button.
If they don't update often, but the user is going to want to be warned without using the app (natural disaster or something), use C2DM
If they update at set times (hourly, daily etc), use a service to pull the updates at those times / intervals.

Categories

Resources