Code example for WifiP2pConfig

0
     * Initiate a connection with the peer. 
     */ 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        WifiP2pDevice device = (WifiP2pDevice) getListAdapter().getItem(position);
        WifiP2pConfig config = new WifiP2pConfig();
        config.deviceAddress = device.deviceAddress;
        config.wps.setup = WpsInfo.PBC;
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        } 
        Log.d("Test", "progressDialogConnectingTo");
        progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel",
                "Connecting to :" + device.deviceAddress, true, true);
        ((DeviceActionListener) getActivity()).connect(config);
    } 
 
    /** 
     * Array adapter for ListFragment that maintains WifiP2pDevice list. 
     */ 
    private class WiFiPeerListAdapter extends ArrayAdapter<WifiP2pDevice> {