Is there any way to end the connection to a peer over Wifi-Direct? I tried cancelConnect and removeGroup. Both of them returned Busy? thanks.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
this is the method I am using to disconnect from peer. I noticed from logs that the android built in app also uses the same method to disconnect the peers.
public static void disconnect() {
if (mManager != null && mChannel != null) {
mManager.requestGroupInfo(mChannel, new GroupInfoListener() {
@Override
public void onGroupInfoAvailable(WifiP2pGroup group) {
if (group != null && mManager != null && mChannel != null
&& group.isGroupOwner()) {
mManager.removeGroup(mChannel, new ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "removeGroup onSuccess -");
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "removeGroup onFailure -" + reason);
}
});
}
}
});
}
}