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) {
Contextual code suggestions in your IDE  Get Codota for Java