Is it possible to detect Android devices laying side by side
Asked Answered
S

6

15

I am developing an Android application that requires devices to be laid side by side and/or above and below each other.

I know I can use the Nearby API to detect devices "Nearby" however I need something a little more "Finer Grained".

My app needs to be able to identify a device laying either on the left side, above, right side or below. While all devices are laying flat on a table (for instance).

I can find nothing on the web that describes this use case.

Is it possible?

UPDATE

My use case is that I want Android devices to be able to detect any number of "Other Devices" laying either to their left or right. The devices will be laid out horizontally with a "small" gap between each one.

In the same way that you might layout children's lettered blocks to spell out a word or phrase, or numbered blocks to make a sum.

not only should the line of devices be able to detect their immediate neighbours to their left and right the two devices at either end should be able to detect they they are the start and end (reading left to right) of the line.

Stumpf answered 12/7, 2017 at 10:32 Comment(7)
Even if there were a phone which could detect position like this, my guess is that not all phones can do this.Candice
would it be an option for you to init the devices by some touch gestures? or do they have to know their position automatically?Buckeye
GPS is the only thing I can think of. However, I'm not sure about the accuracy and it wouldn't work inside a building. You might be able to combine it with NFC.Tenancy
maybe you could use some BT location beacons to determine the position of the 2 devicesMollusc
I hadn't considered GPS. I suspect it wouldn't be accurate enough though @EndreBörcsökStumpf
Bluetooth Low Energy and its rssi signals would work well for the purpose of proximity between devices, positioning and placement could be toughSchwitzer
Can you tell a bit more about the use case? I have an idea how to solve this by using a third phone, but I'm not sure if it's relevantDactylogram
L
5

Using proximity sensors is a likely way to solve your question. TYPE_PROXIMITY will gives the distance from a near by object. TYPE_MAGNETIC_FIELD gives the geomagnetic field strength on x/y/z.

For more read Position Sensors.

Lueluebke answered 25/7, 2017 at 13:0 Comment(1)
Seems not, because TYPE_PROXIMITY sensor determine how close the face of a device is to an object, but not identify a device laying either on the left side, above, right side or below. TYPE_MAGNETIC_FIELD does not give any information about the location of the nearest objects. And even if you put a magnetic tag on the second device, it will be possible to determine only the distance to it, but not the direction.Dynamometry
G
4
  1. Making your own Mock GPS (Local PS to be exact). I don't have a link for this but its definitely possible. Check out how GPS works to get an idea. Wifi and Bluetooth are signals. but you know what else is a signal?

A: SOUND

make each phone make a large beep in turn and measure audio strength using receivers. This might work better than wifi/bluetooth. once you measure relative distances between every pair of phones, it only takes a good algorithm to find relative positions

  1. A Possible Alternative Solution : use image processing. Get something like OpenCV for Android and setup one phone as a master. This will work only for a 2D Layout.

  2. Another "idea" - use the cameras. Stick A board on top of your surface with 4 QR codes in each corner. (This will help identify the edges and orientation of your phone). If you're looking for a 3D layout and the phones have sufficient in-between space, you could stick a QR behind every phone and show a QR on the screen of every phone.

All of these are solutions. Maybe you can use individual ones. Maybe you can use a combination. who knows.

Gastrotrich answered 28/7, 2017 at 14:47 Comment(0)
D
2

An idea, in case it's relevant for your use case:

  • Setup phase
    • start your app on each device in "pairing mode".
    • Each device will show a QR code containing the key required for communicating with the device (for example via Firebase), and screen details: size in pixels. It will also draw a rectangle at the screen boundaries.
    • A different phone, external to this layout will run your app as a "master", taking a picture of the phones from above.
    • Now you need to write an algorithm to identify the screens and their locations, orientation and extract the QR codes for analysis. Not easy, but doable.
  • Interaction phase
    • now all the phones (this should work on more than two phones) can collaborate screens to show parts of the same movie, for example.
Dactylogram answered 27/7, 2017 at 10:52 Comment(0)
D
1

Seems not, if You have only 2 devices, but if You have external sources (with known position) of any signal (audio, vibrate, BT or WiFi radio, etc.), which can be detected by devices with adequate accuracy, and devices time is synchronized, You can do this comparing time of signal start (or signal strength) on both devices like on this picture:

Example

Or, if You can add some sensors to one of devices, You can create "other device locator", for example like this sound locator.

UPDATE

In a updated formulation, the issue is also not solvable: it's possible to determine which two devices are at the edge, but you can not determine which one is on the left and which is on the right side. It is necessary that at least one device knows that it, for example, is leftmost - then other devices, for example, generates a sound, the others receive it and determine their order according to the difference in arrival time. But the anchor point and synchronization of time are necessary.

Dynamometry answered 24/7, 2017 at 18:16 Comment(4)
@Stumpf Running with this idea (detect time of a "known" signal) you might try having the first machine in the line emit a "beep" of some kind, and have the remaining devices listen for it... This might be sufficient to determine their relative order. Propagation time for sound will (I imagine) be so much less than BT/wifi that you're more likely to be able to resolve the differences. This wouldn't tell if they're arranged in a line, but might give the order if they are.Melli
@Melli "This might be sufficient to determine their relative order" - only by distance, not by direction (location), for example: two devices, on the left and on the right side at same distance will receive a signal simultaneously.Dynamometry
That's why I suggested the end device being made to emit the sound... all the others (if in a straight line) would hear it at slightly different times. And as I said, it could be fooled if the devices weren't in a line. It might just be the best the OP can do. (A more complicated option, if the original idea could be made to work at all, would be for all the devices to emit beeps at slightly frequencies, then it might be possible to "triangulate" among each other to get some idea of relative positioning).Melli
@Melli I agree that in this case we can determine "end device", but not "left end device" or "right end device".Dynamometry
A
1

By understating your use case, it is possible to find number of devices surrounded by host device, using Nearby Api, other techniques. But find how many devices each side!!! I don't think it is possible with the current mobile hardware and technology. Because, by considering all factors, magnetic sensors are only the least possible solution. But the current mobiles have no such capability.

The following point I made based on above answers. TYPE_ACCELEROMETER, TYPE_LINEAR_ACCELERATION, TYPE_MAGNETIC_FIELD, TYPE_ORIENTATION these sensors are react to the magnetic field around the device (compass react to the magnet). You can try an app using TYPE_MAGNETIC_FIELD, test how it will react to other device when close to it (I think it will react).

But the point I am trying to make here is, if you put three devices to once side and 4 devices to other side, the MAGNETIC_FIELD sensor reads relative magnetic field. So we can't identify how may devices each side, Until unless you have made some scientific calculations.

The second point is, some one suggested TYPE_PROXIMITY sensor, but it is not meant to serve this purpose. Current mobiles, measures the proximity of an object in cm relative to the view screen of a device. This sensor is typically used to determine whether a handset is being held up to a person's ear.

Another least possibility is using location sensor, it can identify the coordinates relative to your device coordinates, you communicate between each device coordinates with host using NFC. But the problem is, your use case says those devices are very close to each other, so it is not measurable distance using location service.

To conclude, it is not possible to identify number of each devices each side of a host device, with the current mobile hardware. It will can archived by using external sensor that will extends the mobile capability. For example, a phone case that equipped with such a capability, this will open window to other use-cases and application as well.

Add answered 27/7, 2017 at 16:54 Comment(0)
D
-1

I think a way but it may require a a bit work. First check if 2 devices are laying by getting device orientation and using accelerometer or rotation vector to check pitch, roll, etc.

When you are sure that they are laying send data from one device from one to another using BT or wifi. Data should include send time. Check retreive time on other device also you should check for latency for sending and retreiving data. If you can have a noticible time differences in ms for small distance differences between devices it would be easy to check how approximately close they are. Also you may ask users to hold their device 1 meter or fixed distance from each other to get a time of travel for BT or wifi signal you send to other.

Disembarrass answered 27/7, 2017 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.