Android Question Code translation for Wifi-Direct programmatical disconnection

toby

Well-Known Member
Licensed User
Longtime User
I've found the following java code from stackover flow:
B4X:
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) {
                    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);
                        }
                    });
                }
            }
        });
    }
}

I'm hoping that some Java Expert could translate the code to B4A.

TIA
 
Last edited:

toby

Well-Known Member
Licensed User
Longtime User
I was too lazy to read the example code carefully; I just read it again and tested it a few times and it seems to me that the following code should do the trick.

B4X:
Private Sub btnDisconnect_Click
    astream.Close
    ToastMessageShow("connection closed", False)
End Sub
 
Upvote 0
Top