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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With