WiFi Direct reassigning Group Owner during ongoing connection
You can not change the GO on active connections, thus yes, you do need to disconnect all devices first.
If you have a logic to determine which one is going to be the GO, then I would suggest using CreateGroup function to create the GO, and have others to connect to it once they see it advertising its presence.
How to add a device to a WifiP2pGroup in Android
You'd use one device to createGroup
and then use the other devices to discoverPeers
and requestPeers
.
When onPeersAvaiable
, You'd then iterate through the WifiP2pDevice
's and call the isGroupOwner
method on each device.
For each group owner address obtained, the client would then connect
to the group owner.
Once a connection has been established, you would call requestConnectionInfo
.
When onConnectionInfoAvailable
you would check the WifiP2pInfo
object to ensure the groupFormed
boolean was true.
Then, using the groupOwnerAddress
InetAddress, You can use Java Sockets to send signals between the two.
You could then send a string to the group owner saying 'BLAH BLAH BLAH UNIQUE VALUE'. If the group owner returns 'I UNDERSTAND' then you know the group owner belongs to your application. I the group owner returns anything else, or does not reply, then you know the group owner is invalid.
If you are using API 16+, you can use Service discovery to check whether a device is running your app, and THEN connect.
Related Topics
Clear Application Cache on Exit in Android
Changing the Screen Brightness System Setting Android
Opencv Image Comparison in Android
How to Get the Current Dns Servers for Android
Android Notification with Buttons on It
Android:How to Change Playback Rate of Music Using Opensl Es
Change Date String Format in Android
How to Change the Generated Filename for App Bundles with Gradle
Setting a Maximum Width on a Viewgroup
Do Gcm Registration Id's Expire
How to Customize the Action Mode's Color and Text
How to Launch the 'Add Contact' Activity in Android
No Notification Sound When Sending Notification from Firebase in Android
Android - Use External Profile Image in Notification Bar Like Facebook
How to Use Tabhost.Ontabchangelistener in Android