Vinit Shandilya Vinit Shandilya - 7 months ago 75
Android Question

WiFi Direct device connection with other Android devices

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 specialized hardware to be present on both devices? Will network discovery work in such cases?


It is possible. Code taken from a talk I gave at Droidcon UK 2013.

You need to call the createGroup(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener) method of the WifiP2pManager class. This will create a Wi-Fi Direct group that supports legacy Wi-Fi connections.

Prior to the call, you need to register a broadcast receiver similar to this:

BroadcastReceiver receiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
                new WifiP2pManager.GroupInfoListener() {
                public void onGroupInfoAvailable(WifiP2pGroup group) {
                    if(group != null){
                        // clients require these
                        String ssid = group.getNetworkName(),
                        String passphrase = group.getPassphrase() 

The other devices can then use Wi-Fi to connect to the Wi-Fi Direct device, once they have the ssid and passphrase.