Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Beacon (Eddystone) with Android Nearby API

Tags:

java

android

I'm trying to detect beacons around me, but with the Nearby API, i can't seem to find them.

I'm using this method to detect nearby devices :

public void startDiscovery(String serviceId, final OnDiscoveryListener l) {

    Nearby.Connections.startDiscovery(googleApiClient, serviceId, Connections.DURATION_INDEFINITE, new Connections.EndpointDiscoveryListener() {
        @Override
        public void onEndpointFound(String endpointId, String deviceId, String serviceId, String endpointName) {
            if (l != null) {
                l.onEndpointFound(endpointId, deviceId, serviceId, endpointName);
            }

        }

        @Override
        public void onEndpointLost(String s) {
            if (l != null) {
                l.onEndpointLost(s);
            }
        }
    })
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    if (l != null) {
                        l.onResult(status);
                    }
                }
            });
}

The listener looks like this :

public interface OnDiscoveryListener {
    public void onResult(Status status);

    public void onEndpointFound(String endpointId, String deviceId, String serviceId, String endpointName);

    public void onEndpointLost(String s);
}

But i can't detect anything

like image 291
Tsunaze Avatar asked Aug 03 '15 08:08

Tsunaze


1 Answers

I work on the Nearby API at Google. The code snippet above uses the Nearby Connections API--which is actually geared towards different use-cases. To work with Eddystone, use the Nearby Messages API. Here's an example of using Nearby Messages to subscribe to the presence of beacons

Note that you need to first associate a Message payload with the beacon using the Proximity Beacon API.

like image 149
Andrew Bunner Avatar answered Oct 30 '22 16:10

Andrew Bunner