我正在使用此处提供的示例应用程序测试 Nearby 连接 API:https ://github.com/googlesamples/android-nearby 这似乎不适用于某些设备。我成功地将三星 Galaxy S3 与 Nexus 7 双向连接(S3 作为主机,N7 作为从机,反之亦然)。但是,当我尝试将 Samusung Galaxy S3 连接到 Nexus 5 时,连接总是失败,状态码为 8005。
下面你可以看到slave(发现设备)为了连接到主机(广告设备)而调用的方法。
private void connectTo(String endpointId, final String endpointName) {
debugLog("connectTo:" + endpointId + ":" + endpointName);
// Send a connection request to a remote endpoint. By passing 'null' for the name,
// the Nearby Connections API will construct a default name based on device model
// such as 'LGE Nexus 5'.
String myName = null;
byte[] myPayload = null;
Nearby.Connections.sendConnectionRequest(mGoogleApiClient, myName, endpointId, myPayload,
new Connections.ConnectionResponseCallback() {
@Override
public void onConnectionResponse(String endpointId, Status status,
byte[] bytes) {
Log.d(TAG, "onConnectionResponse:" + endpointId + ":" + status);
if (status.isSuccess()) {
debugLog("onConnectionResponse: " + endpointName + " SUCCESS");
Toast.makeText(MainActivity.this, "Connected to " + endpointName,
Toast.LENGTH_SHORT).show();
mOtherEndpointId = endpointId;
updateViewVisibility(STATE_CONNECTED);
} else {
debugLog("onConnectionResponse: " + endpointName + " FAILURE. ResponseCode=" + status.getStatusCode() + " statusMessage=" + status.getStatusMessage() );
}
}
}, this);
}
我总是得到的结果是:
11-17 18:48:50.678 11133-11133/com.google.example.connectionsquickstart D/MainActivity:onConnectionResponse:Samsung GT-I9300 FAILURE。响应代码=8005 状态消息=空
有什么线索吗?