0

So basically I have made a few small apps in the past, but this is my first 'proper' app.

One of the main features of the app, and the bit that I am struggling with is that I need to be able to populate a ListView with all of the other users logged into the app, however I only want to display users that are within a set distance, for example 10 meters.

I tried using Bluetooth to achieve this, however that didn't work. I would now like to use location services to do this.

My idea is to have to app send the location of the device to an external server every few minutes and then all other devices can run a function that compare their location to others found on this server.

Does anybody know how I could go about achieving this, or know of any tutorials that cover a simpler topic. Thank you

1

1 Answer 1

6

Disclaimer: I'm not an android developer, but this seems like a design issue not a implementation issue so hopefully my comments below might be of some use...

I don't think there's an API that you can just set to "true" to get this functionality, so I think you're going to have to custom craft all the moving parts (and there are a couple). I would think the general process would be something like:

On the client:

  1. User on client logs in to server with some sort of identity (i.e. "user@gmail.com")
  2. Every X minutes the client app gets the current location (i.e. "100N 90E") and sends it up to a server
  3. Every X minutes the client polls the server to see who is within 10 miles (i.e."joe@gmail.com", "mary@gmail.com")

On the server:

  1. Needs some sort of authentication endpoints for getting a user's identity
  2. Needs an endpoint for users to register their location ("user@gmail.com is at 100N 90E")
  3. Needs a service to find out how far each user is from each other
  4. Needs an endpoint to return the users within X miles (list generated from #3)

Each one of these steps shouldn't be difficult on their own and you can actually get pretty nuts with the distribution algorithm on server step #3 if you wanted to.

Some questions you can ask yourself are:

  • "How do I set up a server to listen for HTTP requests?" - Take a look into Node.JS for a simple solution
  • "How do I get a user's location in android?" - Easy google search finds plenty of documentation
  • "How do I write a service to continuously perform actions?" - Node.JS would again help with this
  • "Where will I store user's locations and their distances from each other?" - You can look into a NoSQL option like CouchBase or MongoDb. Or you could use MySQL for a more structured database.

Hope this helps...

3
  • Yes, that is exactly what I want to do, I'm just not sure how to implement it into my application. Sep 6, 2014 at 22:01
  • @JoshLittlewood - I made my answer a little more robust. The implementation is going to be a bit of a custom job, so not sure you're going to find a single sample that does exactly what you want, but if you get stuck on any particular piece then I'm sure someone on stackoverflow could help out...
    – jt000
    Sep 6, 2014 at 23:29
  • @JoshLittlewood Couchbase is great for NoSQL document datastore and fits what you are trying to do too being that you can evolve the schema as you develop your application/feature. Sep 8, 2014 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.