Android Question Proper way to end a WiFi-Direct Connection

Robert Valentino

Well-Known Member
Licensed User
I cannot seem to end and then start again a WiFi-Direct Connection.

Can someone explain to me what has to be done and what order?

B4X:
    Private manager                             As WifiManager
    Private server                             As ServerSocket
    Private client                             As Socket
    Private astream                         As AsyncStreams

I've tried these in different orders
B4X:
                astream.Close                
                client.Close
                server.Close
                manager.CancelConnections

I would think there must be a nice clean way to shut down and then restart the connection process again.

It seems after being connected my only way to redo the connection is to turn off WiFi and then turn it back on.
 

Robert Valentino

Well-Known Member
Licensed User
Well here is my conversion to B4XPages.

Made the whole WiFiDirect as separate page so it is easy to plug in.

Must click on Discover on both devices.
List of devices available will be shown.
Click on one you want to connect to

Still haven't figured how to easy shut everything down, if and when I do will repost.
But have added a button "Try Reset WiFi" that opens the Wifi settings dialog so you can turn off and on again and that seems to fix any problems

Enjoy

BobVal

PS: Choose landscape mode because that's how devices sit above my keyboard.
 

Attachments

  • Project.zip
    39.5 KB · Views: 66
Upvote 0
Top