Code example for WifiP2pConfig

     * Attempts to initiate a connection to the given device 
     * @param device The device of interest 
	public void connectToDevice(WifiP2pDevice device) {
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = device.deviceAddress;
		manager.connect(channel, config, new ActionListener() {
			public void onSuccess() { 
                Toast.makeText(getApplicationContext(), "Connected to Device!", Toast.LENGTH_SHORT).show();
                Log.d(MyApplication.this.TAG, "Device Connected!");
                for(OnDeviceConnectedListener listener : deviceConnectedListeners) {
Connect your IDE to all the code out there  Get Codota for Java