Can I connect a WiFi Direct enabled device to any other device which doesn\'t have WiFi Direct feature but supports WiFi hotspot connection? Does WiFi direct uses specialize
Stephen's answer is great, but I found it's better to get the group info at
WIFI_P2P_CONNECTION_CHANGED_ACTION
...
if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
NetworkInfo networkInfo = intent.getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
WifiP2pInfo wifiP2pInfo = intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO);
if (networkInfo.isConnected() && wifiP2pInfo.groupFormed) {
if (wifiP2pInfo.isGroupOwner) {
wifiP2pManager.requestGroupInfo(channel, new WifiP2pManager.GroupInfoListener() {
@Override
public void onGroupInfoAvailable(final WifiP2pGroup wifiP2pGroup) {
if (wifiP2pGroup != null) {
// clients require these
String ssid = wifiP2pGroup.getNetworkName();
String passphrase = wifiP2pGroup.getPassphrase();
...
}
}
}
}
}
}
}
...
Because this can make sure the access point is created and current device is the group owner (GO).