Is it possible to find other nearby phones?
Asked Answered
M

2

15

I'm writing an Android app that I would like to eventually port to iOS and Windows Mobile (though I know absolutely nothing about them right now). I'd like my app to be able to find other phones within a certain radius (maybe 20-30 feet) that also have the game installed so that the users can interact with others in their current physical space. Is this possible and, if so, how?

I plan on the app requiring an internet connection so my first thought was to use GPS like described at iOS Find Other Nearby Devices (GPS locations), but that would require continually transmitting data to the server to update the user's location using both bandwidth and battery (not to mention the server resources). GPS also seems to take a while to get any sort of accurate fix, and even though I wouldn't store historical data I wouldn't expect users to trust me with that sort of private information (as well they shouldn't!)

I know there are proprietary technologies, such as Sony's NFC, but that's far too narrow a focus to use for an app that I'd like to be device and OS agnostic. What other options are there? Assuming the user is willing to give the app the appropriate permissions, what other methods could allow one device to find another nearby one, within a 10-15 meter range, that is practical for a large (million+) userbase? Is HTML5 Geolocation a better path? Or is GPS my only real option?

I did find Use Android GPS to detect and connect with other phones, but was hoping the past few years have opened up further options.

UPDATE

Thank you for all the responses so far. To answer some questions posed in the comments and answers, I thought I'd describe how I expect the apps/devices to interact.

All users who install this app will have an agent running in the background to update their current geolocation and to listen for pings. Any user may open the full program and send a quick request for all other users nearby. If I go the central server route, then the server responds to that request with a list of nearby usernames. The user can then pick one of those to initiate a connection, in which case the target device makes a sound to notify of a request to connect.

From there it's easy enough to handle the interaction between two devices. Finding those nearby users is the sticking point for me.

Meshed answered 8/1, 2014 at 21:16 Comment(4)
if you wanted to support Android 4.3+, you could have a look at BlueTooth Low Energy. Coupled with an iBeacon sort of setup, you can have each phone running your app broadcasting its location to those around itFlexuous
I'm thinking high pitched ping to see who's near byParker
What level of interaction?Sunshine
similar thread here, besides not giving an answer it contains some interesting info #51407816Packet
L
14

Options I can see

  1. Bluetooth (BT). I don't know, if I'm not too skeptical about it, but I see couple of problems. Short range. The biggest energy consumption. Maximum 7 peers connected at the same time (but maybe it's enough...). The big advantage is that a lot of devices support BT.

  2. BT LE (low energy). Ok, it helps energy consumption problem. But, requires Android 4.3.

  3. WiFi Direct (aka P2P). I gave it a shot, I'm a bit disappointed. The problem is that it needs Android 4.0 or higher. Even worse, some devices don't have required hardware. I launched WiFiDirectDemo from Android samples on Samsung Xperia Miro ST23i. Clicked on "search" and the only thing I got was a toast "enable WiFi P2P - in your settings". I clicked on everything in that settings, there is just normal WiFi and other stuff, no mention about Direct or P2P. Xperio Miro just doesn't support WiFi Direct.

  4. WiFi connection with a server through internet + device geolocation. Server keeps positions of users and answers questions like "who is 20 feet in my range?". The problem can be the precision of geolocation. If the walls are thick or you are in a place on earth with few satellites - it can be very inaccurate.

To sum up

There is greater probability that somebody will have WiFi turned on all the time than BT. BT also have some time limits after which it is turned off (they make it this way to probably save battery). So, WiFi seems a better choice than BT.

If WiFi Direct is popular enough for you - I would give it a try. If not, option number 4 seems the best. It's not ideal, I know, but at this point it's hard to come with something better (we still need technology development, WiFi Direct looks promising).

Loisloise answered 8/1, 2014 at 21:19 Comment(5)
For Option 4, IOS, at least, supplements GPS with WiFi access point geolocation. The most populous locations with poor GPS are urban canyons and building interiors, and they tend to have WiFi access points.Ramires
Android can also get your location with WiFi and cell towers.Sunshine
Thank you for the response. Would number 4 be most reliably achieved through HTML5 geolocation within a webview? I've never used GPS in an app before; how quick and how accurate is it?Meshed
@Meshed You're welcome. It depends a lot on the circumstances - you should just test it and see how it works.Loisloise
@AdamStelmaszczyk I will definitely give it test, but if I'm in an optimal area I'll be overconfident of its performance, while if I'm in a suboptimal area I may be overly pessimistic. So I was hoping to incorporate others' experiences into my assessment as well.Meshed
S
4

I would use the central server approach. Each phone sends position data to the server. The server notifies the other users when they are in range. To limit used data, only send positions when the device reports movement more then X meters.

Also, consider using a Ping button. The user presses it to send the position when they wish to find someone nearby. Position data would only be sent on this ping. This would use very little power and provide good privacy.

It might be possible to detect details about the connected Wifi access point. If you could get the AP or Gateway's MAC address, you could send that as a kind of position. All the players on the same Gateway would be close by.

Striate answered 8/1, 2014 at 21:53 Comment(1)
Any idea on how to implement a algorithm on this central server. Lets say its a MySQL server with a location table showing all users' last updated location. Or even better are there solutions already out there?Disturbing

© 2022 - 2024 — McMap. All rights reserved.