Reputation: 21
I just add two buttons on the WiFiDirectDemo provided by Google. One of the button is called "Owner" and the other is "Client".
I what two device to choose if they what to be the owner or not.
In the beginning, I thought it would work if I change the number between 0 and 15:
config.groupOwnerIntent = 0;
But it didn't work.
One of the device keeping act as Group Owner. Even if I change the "groupOwnerIntent".
Here is my code ( DeviceDetailFragment.java ):
mContentView.findViewById(R.id.btn_owner).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
intentNumber = 15;
Toast.makeText(v.getContext(),String.valueOf(intentNumber),
Toast.LENGTH_LONG).show();
}
});
mContentView.findViewById(R.id.btn_client).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
intentNumber = 0;
Toast.makeText(v.getContext(), String.valueOf(intentNumber),
Toast.LENGTH_LONG).show();
}
});
//********************************************************************
mContentView.findViewById(R.id.btn_connect)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//WifiP2pConfig config = chooseOwner(ownerIntentNumber);
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
config.groupOwnerIntent = intentNumber;
Toast.makeText(v.getContext(), String.valueOf(intentNumber),
Toast.LENGTH_LONG).show();
}
});
Please give me some advise. Thank you very much.
My devices are two Nexus 7.
Upvotes: 2
Views: 2164
Reputation: 1
Another common mistake I made: The the device on which the Owner/Client button is pressed (to change the config groupownerintent value) must initiate the connection by pressing the connect button and not the other device.
Upvotes: 0
Reputation: 91
I just suffered with same problem.
In my case, that happened because Wi-Fi Direct
group was remembered by the device.
In Galaxy Nexus, I could forget it by changing setting in
Setting
-> Wi-Fi
-> Wi-Fi Direct
-> Select the group remembered -> Forget
And then, I could change the group owner as I configured.
Upvotes: 1