Code example for WifiP2pDeviceList

Methods: getDeviceList

0
    public void onReceive(Context context, Intent intent) { 
      wifiP2pManager.requestPeers(wifiDirectChannel,  
        new PeerListListener() { 
          public void onPeersAvailable(WifiP2pDeviceList peers) { 
            deviceList.clear(); 
            deviceList.addAll(peers.getDeviceList()); 
            aa.notifyDataSetChanged(); 
          } 
        }); 
    } 
  }; 
   
  /** 
   * 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);
  }