I\'m currently trying to connect two phones which know each other\'s MAC address via Wi-Fi Direct, and stumbled upon the following problem: The MAC address, which I receive
I was struggling all night to figure out a way to retrieve WiFi Direct mac address instead, since my requirements were drafted around the assumption that it's feasible.
It's kind of round about, you create a single device group and get the owner and the device address along with it.
Here's the code,
final WifiP2pManager p2pManager = (WifiP2pManager) getSystemService(WIFI_P2P_SERVICE);
final WifiP2pManager.Channel channel = p2pManager.initialize(this, getMainLooper(), null);
p2pManager.createGroup(channel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
p2pManager.requestGroupInfo(channel, new WifiP2pManager.GroupInfoListener() {
@Override
public void onGroupInfoAvailable(WifiP2pGroup wifiP2pGroup) {
Log.i("", wifiP2pGroup.getOwner().deviceAddress);
// Following removal necessary to not have the manager busy for other stuff, subsequently
p2pManager.removeGroup(channel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
Log.i("", "Removed");
}
@Override
public void onFailure(int i) {
Log.i("", "Failed " + i);
}
});
}
});
}
@Override
public void onFailure(int i) {
Log.i("", String.valueOf(i));
}
});