MessageListener.onDistanceChanged 未被调用
MessageListener.onDistanceChanged not being called
我正在通过 Google Nearby 发布和订阅消息,并正确接收 onFound 和 onLost,但未收到 onDistanceChanged 或 onBleSignalChanged 的任何回调。我知道 BLE 信号改变是基于使用 BLE 发现,但是 onDistanceChanged 是否有类似的限制?文档似乎没有表明存在。下面是我的消息监听器,感谢您的任何建议!
mMessageListener = new MessageListener() {
@Override
public void onFound(Message message) {
String messageAsString = new String(message.getContent());
Log.d(TAG, "Found message: " + messageAsString);
}
@Override
public void onLost(Message message) {
String messageAsString = new String(message.getContent());
Log.d(TAG, "Lost sight of message: " + messageAsString);
}
@Override
public void onDistanceChanged(Message message, Distance distance) {
super.onDistanceChanged(message, distance);
Log.d(TAG, "New distance "+distance.getMeters()+" to message: " + new String(message.getContent()));
}
@Override
public void onBleSignalChanged(Message message, BleSignal bleSignal) {
super.onBleSignalChanged(message, bleSignal);
Log.d(TAG, "New ble signal " + bleSignal.getRssi() + " to message: " + new String(message.getContent()));
}
};
您可能无法收到回调的原因有两个:
- 遗憾的是,距离回调目前仅适用于 BLE 信标消息。我们已经修复了文档,但它们不会在网络上更新,直到下一个 Google Play Services SDK 发布(几周后)。我们希望在未来让它适用于更多消息。
- 不为 subscribe() 的 PendingIntent 版本调用 BLE 信号和距离回调。
我正在通过 Google Nearby 发布和订阅消息,并正确接收 onFound 和 onLost,但未收到 onDistanceChanged 或 onBleSignalChanged 的任何回调。我知道 BLE 信号改变是基于使用 BLE 发现,但是 onDistanceChanged 是否有类似的限制?文档似乎没有表明存在。下面是我的消息监听器,感谢您的任何建议!
mMessageListener = new MessageListener() {
@Override
public void onFound(Message message) {
String messageAsString = new String(message.getContent());
Log.d(TAG, "Found message: " + messageAsString);
}
@Override
public void onLost(Message message) {
String messageAsString = new String(message.getContent());
Log.d(TAG, "Lost sight of message: " + messageAsString);
}
@Override
public void onDistanceChanged(Message message, Distance distance) {
super.onDistanceChanged(message, distance);
Log.d(TAG, "New distance "+distance.getMeters()+" to message: " + new String(message.getContent()));
}
@Override
public void onBleSignalChanged(Message message, BleSignal bleSignal) {
super.onBleSignalChanged(message, bleSignal);
Log.d(TAG, "New ble signal " + bleSignal.getRssi() + " to message: " + new String(message.getContent()));
}
};
您可能无法收到回调的原因有两个:
- 遗憾的是,距离回调目前仅适用于 BLE 信标消息。我们已经修复了文档,但它们不会在网络上更新,直到下一个 Google Play Services SDK 发布(几周后)。我们希望在未来让它适用于更多消息。
- 不为 subscribe() 的 PendingIntent 版本调用 BLE 信号和距离回调。