0

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?

user22845
  • 11
  • 3
  • possible duplicate of [Android SMS intercept without notification icon or WAP-PUSH messages](http://stackoverflow.com/questions/1732537/android-sms-intercept-without-notification-icon-or-wap-push-messages) – Sufian Mar 14 '15 at 20:29

1 Answers1

1

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

nickfox
  • 2,835
  • 1
  • 26
  • 31
  • Thank you for your answer. I was hoping to find a method where I do not have to store the location of the phone on the server, as this would mean my server is regularly tracking my app users. I'm looking for a solution where every app user receives the message but then the receiving phone itself decides if its withing range and then decide whether to prompt the user or just discard the message before prompting. – user22845 Mar 16 '15 at 13:30