问题
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);
}
});
}
}
});
}
}
来源:https://stackoverflow.com/questions/18679481/wifi-direct-end-connection-to-peer-on-android