gpt4 book ai didi

android - 适用于 Android 的附近连接 API - 不适用于某些设备

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:01:24 26 4
gpt4 key购买 nike

我正在使用此处提供的示例应用程序测试 Nearby 连接 API:https://github.com/googlesamples/android-nearby这似乎不适用于某些设备。我成功地将 Samsung Galaxy S3 与 Nexus 7 双向连接(S3 作为主机,N7 作为从机,反之亦然)。但是,当我尝试将 Samusung Galaxy S3 连接到 Nexus 5 时,连接总是失败,状态代码为 8005。

下面你可以看到slave(发现设备)为了连接到host(广告设备)调用的方法。

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:三星 GT-I9300 失败。 ResponseCode=8005 statusMessage=null

有什么线索吗?

最佳答案

您遇到的错误是 STATUS_NOT_CONNECTED_TO_ENDPOINT(来自 Reference docs)。两台设备都需要连接到具有互联网访问权限的同一 WiFi。

关于android - 适用于 Android 的附近连接 API - 不适用于某些设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33763874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com