How to make a specific group owner in Wifi-Direct Android

Hammad Shahid picture Hammad Shahid · Sep 9, 2013 · Viewed 8.4k times · Source

I have an Wifi Direct Android Application which will run on two Phones.

When phone1 connects to phone2 , I want phone1 to act as a client and phone2 to act as a server.

I used this code:

if (info.groupFormed && info.isGroupOwner) {

           // start the server thread

   } else if (info.groupFormed) {

            // start the client thread
   }

But the problem is that , sometimes phone1 which has initiated the connection and I want it to act as a client , it sometimes acts as a GroupOwner, and the server thread is started on the client phone.

I want to make sure that phone2 always act as a GroupOwner and a server.

Answer

Hammad Shahid picture Hammad Shahid · Sep 9, 2013

To set a peer as a client , not a GroupOWner eachtime , we have to assign:

config.groupOwnerIntent = 0;