【发布时间】:2015-10-18 08:51:30
【问题描述】:
我正在尝试通过 wifi 直接连接两个设备。我将组所有者意图设置为 15,如下所示:
config.groupOwnerIntent = 15;
但它根本不起作用。此外,我尝试删除所有以前保存在设备中的组,以防影响 GO 选择。 其他设备一直在运行。您知道可能是什么问题吗?
【问题讨论】:
标签: android wifi-direct
我正在尝试通过 wifi 直接连接两个设备。我将组所有者意图设置为 15,如下所示:
config.groupOwnerIntent = 15;
但它根本不起作用。此外,我尝试删除所有以前保存在设备中的组,以防影响 GO 选择。 其他设备一直在运行。您知道可能是什么问题吗?
【问题讨论】:
标签: android wifi-direct
基本上,如果您希望其他设备成为群组所有者,则使用 CreateGroup 函数在该设备上创建群组。
【讨论】:
问题在于config.groupOwnerIntent = 15; 使用相同的品牌(例如,如果您的两台设备都是三星)。使用不同的设备有时会出现此错误。
这也取决于您的连接:
manager.connect(channel, config, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
Toast.makeText(context, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
或
manager.createGroup(channel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
// Device is ready to accept incoming connections from peers.
}
@Override
public void onFailure(int reason) {
Toast.makeText(WiFiDirectActivity.this, "P2P group creation failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
如果您使用第二个代码,您的代码将无济于事。
现在三星和小米都有同样的问题,总是同一个群主。如果对两个三星都进行测试,一切正常。
【讨论】: