Code example for WifiP2pConfig

    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() {
            public void onSuccess() { 
                //success logic 
                Log.d(TAG, "connected to "+addr);
            public void onFailure(int reason) {
                //failure logic 
                Log.d(TAG, "could not connected to "+addr);
Contextual code suggestions in your IDE  Get Codota for Java