Code example for WifiP2pConfig

0
   
  /** 
   * Listing 16-23: Requesting a connection to a Wi-Fi Direct peer 
   */ 
  private void connectTo(WifiP2pDevice device) {
    WifiP2pConfig config = new WifiP2pConfig();
    config.deviceAddress = device.deviceAddress;
 
    wifiP2pManager.connect(wifiDirectChannel, config, actionListener);
  } 
   
  /** 
   * Listing 16-24: Connecting to a Wi-Fi Direct peer 
   */ 
  BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() {
    @Override 
    public void onReceive(Context context, Intent intent) { 
       
      // Extract the NetworkInfo 
      String extraKey = WifiP2pManager.EXTRA_NETWORK_INFO; 
      NetworkInfo networkInfo =