API to detect distance between Wear watch & Android phone? - android

In my application, we want to warn the user when he is at distance from Phone or watch.
We are scanning nearest nodes using APIs of wear OS.
Is there any way I can detect the distance between two such nodes?
Getting geolocation of both & calculate distance using formula is one possible way.
But aren't the APIs on wear OS has something which can detect distance using Bluetooth range or signal strength?

The best that's directly supported by the platform is the Node API's isNearby method, but that essentially just returns true iff the phone-watch connection is over Bluetooth rather than cellular or wifi. It doesn't give you anything resembling a real distance number.
Beyond that, you'd have to roll your own solution using GPS on both devices, as you mention. But that has a lot of downsides: complexity, reliability, and battery use are ones that immediately occur to me. Someday, you'll be able to get this kind of accuracy from the fused location provider using wifi, but probably not for some years.

Related

Javascript geolocation - GPS settings - FINE vs COARSE

I am creating a geolocation app with Intel XDK (iPhone and Android) and have 2 questions:
How can I display the geolocation settings of the device if the GPS is not active on the phone?
How do I know if the latitude and longitude values returned are from the GPS or from the wifi/data coords? I figured that wifi/data returns a short value (eg: 43.475748) and GPS returns a longer value (eg: 43.47573849384) Am I correct in thinking this?
1.) Most devices will cache the last known geo location. Unfortunately, this behavior is not consistent, and there's not much you can do to change that other than attempt to remember a set of last known locations within your app.
2.) I don't think the HTML5 geo API provides that level of detail, but you could look at the accuracy information that is provided. The designation of "fine" versus "coarse" is somewhat arbritraty, since it means different things on different devices and operating systems (the nature of cross-platform applications). I would use the accuracy feedback as a relative guide.
If you want to play with the geo location feature, checkout the "hello-cordova" sample app in the XDK, it is very easy to use to see how the geo feature works on a variety of devices. You can use it in App Preview or simply build the app and install it on a variety of devices. Note that if you first push the "fine" button then the "watch" button will retrieve "fine" results. If you push the "coarse" button before pushing the "watch" button the watch results will be based on a "coarse" setting.
In general, it is best to first request a "coarse" reading (with a short timeout) to get a general location (or a cached location) and then switch to a "fine" request if you need a more precise location. Battery life will be better if you stick to infrequent "coarse" readings, especially if you only need to know the general location of your user (for example, in which town or neighborhood are they located).

Google Nearby Messages - Cancel initial link between devices

I'm building a app to test Google Nearby Messages API. For that test, I'm using DISTANCE_TYPE_EARSHOT.
According to this thread Nearby API's Strategy.DISTANCE _TYPE_ EARSHOT doesn't seem to restrict message proximity , after the initial link between devices, they can receive messages for 10 minutes regardless of distance. I would like to know if this 10 minute limit can be interrupted (in order to prevent that a device can receive a message when its distance to another device is more than ~5ft - EARSHOT).
Alternatively, is there a way to get the distance between devices?
Thank you.
(I work on the Nearby API)
Today, Nearby doesn't expose distance directly nor does it provide a way to force "un-pairing" of devices programmatically. We've heard folks want both of these things, the features are on our radar, but we can't comment or commit beyond that.
As a manual hack, you can clear data on "Google Play Services" to un-pair devices.
You can get a rough approximation of distance by measuring BLE RSSI if one of the devices is capable of BLE advertising. This will be sensitive to how the device is held, antenna gain and environmental factors but better than random.
There's not a straight-forward "tape measure" API, though.

Detecting when an Android device is in a certain location

What's the best way of detecting when an Android device is in a certain location? I'm creating a device admin app that enforces certain policies when the device is in a certain premise, e.g. a certain office building, and in order to enforce the policies, I need to know where the device is, and the Device Administrator API does not have any geo-location/geo-fence APIs.
I can think of a few methods, but none are foolproof:
Poll fine location (Wifi/GPS) - dependent on whether user has Wifi/GPS on. Impossible to enforce. Also, GPS doesn't work indoors and drains battery significantly.
Poll course location(cell tower) - more reliable, but inaccurate.
Place wifi routers around premises and detect when they are near - dependent of whether user has Wifi on.
What's the best way of detecting a device's location?
The only thing that meet your requirements are iBeacons or comparable devices.
That are blue tooth low energy beacons. Which are mounted on walls in the building.
They emit a beacon id and the distance to that device. You have to manage which beacon id is mounted at which place.
This technique was developed by Apple, so look how you can use that within android.
Outdoors GPS works best, you have to live with battery drain.
Cell Tower locationing you better forget, that has only about 1000m acuracy. Wlan locationing, too is of limited use.

How can I detect if an Android device is indoor/outdoor?

I'm developing an app which fuses location from various providers, hoping it will give a more accurate location than if I simply used the Google API. However, the choice of providers would depend on the phone being indoor or outdoor (Network vs GPS, for example).
What is the best way to detect if the device is indoor or outdoor? My first thought would be using the Light sensor, and maybe cell signal strength and WiFi (if there are WiFi networks near, it's likely the device is indoor), but I don't know which weight/confidence I should attribute to these sensors.
Edit: this is for my masters thesis, in which the goal is to get the location from the different providers (GPS, Network and Passive) in the Android API, and fuse them with a formula. Depending on whether the phone is indoor or outdoor, the several locations would have different weights. There would also be parameters like if battery life is priority or not (I haven't developed this formula yet).
Just subscribe to both providers and use location.getProvider() and location.getAccuracy() when new location arrives--to check if it's more/less accurate then previous.
I'd say your best bet is the GPS signal itself, because GPS rarely penetrates buildings.
In built up areas, you'll encompass WiFi networks all over the shop.

distance between android and iphone

I am looking for a way to transmit data when two phones are close by. This needs to be cross platform so I cannot use NFC or iBeacon. I plan on using allJoyn to send information. I would only like to send data to others that are within a few feet of me.
Is there any way that I could get an accurate reading of distance on other phones? Or can I get an accurate distance on a master device that could be placed in the room?
Shot in the dark answer:
If both devices are on the same wireless WiFi network (same subnet), then any devices on same network are "close enough".
When on the celluar network (or when only one device is on Wifi), use the Location APIs of the platform to get GPS coordinates. Send your coordinates up to a web server that keeps track of the Latitude/Longitude coordinates of each device. The web service also allows the devices to poll for nearby devices (where the distance equation can be computed on the server).
So the best way that I found to do this is to use the accelerometer to tell when two devices bump then I get the bluetooth signal strength of the nearest device, if that falls into a certain value then they are touching.

Categories

Resources