Ram*_*mps 8 android google-nearby
我正在使用此处提供的示例应用程序测试Nearby connection 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);
}
Run Code Online (Sandbox Code Playgroud)
我总能得到的结果是:
11-17 18:48:50.678 11133-11133/com.google.example.connectionsquickstart D/MainActivity:onConnectionResponse:Samsung GT-I9300 FAILURE.ResponseCode = 8005 statusMessage = null
有什么线索是怎么回事?
我假设您正在谈论连接快速入门示例。请在此处查看此 github 问题https://github.com/googlesamples/android-nearby/issues/6 。此示例中使用的 API 显然依赖于多播,这肯定取决于您的路由器,显然也取决于您的设备:
显然你在 Nexus 7 上有这个,但在 Nexus 5 上没有: https://code.google.com/p/android/issues/detail ?id=51195
chuckd73...@gmail.com 这是我们在 Nexus 4 上的一个亮点。我们的应用程序依赖于多播,无法以任何其他方式实现。有趣的是,Nexus 7 确实实现了此功能,但 Nexus 4 却没有。
Jan 8, 2014 #3 jan.zibu...@gmail.com Nexus 5 上问题依然存在。
所以我敢打赌,在您当前的 wifi 上,您可以将 Nexus 7 连接到任何东西。
需要明确的是,您在尝试接收多播数据包时可能会遇到问题:Android 无法接收多播数据包
| 归档时间: |
|
| 查看次数: |
1789 次 |
| 最近记录: |