Code example for WifiP2pManager

Methods: requestConnectionInfo

0
      NetworkInfo networkInfo =  
        (NetworkInfo)intent.getParcelableExtra(extraKey); 
 
      // Check if we're connected 
      if (networkInfo.isConnected()) { 
        wifiP2pManager.requestConnectionInfo(wifiDirectChannel,  
          new ConnectionInfoListener() { 
            public void onConnectionInfoAvailable(WifiP2pInfo info) {  
              // If the connection is established 
              if (info.groupFormed) { 
                // If we're the server 
                if (info.isGroupOwner) { 
                   // TODO Initiate server socket. 
                  initiateServerSocket(); 
                } 
                // If we're the client 
                else if (info.groupFormed) { 
                  // TODO Initiate client socket. 
                  initiateClientSocket(info.groupOwnerAddress.toString()); 
                } 
              }