Code example for WifiP2pManager

Methods: connect

0
    public void connectTo(final String addr, String name) {
        //obtain a peer from the WifiP2pDeviceList 
        WifiP2pDevice device;
        final WifiP2pConfig config = new WifiP2pConfig();
        config.deviceAddress = addr;
        mManager.connect(mChannel, config, new WifiP2pManager.ActionListener() {
 
            @Override 
            public void onSuccess() { 
                //success logic 
                Log.d(TAG, "connected to "+addr);
            } 
 
            @Override 
            public void onFailure(int reason) {
                //failure logic 
                Log.d(TAG, "could not connected to "+addr);
            } 
        }); 
    }