Code example for WifiP2pManager

Methods: connect

	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) {
			public void onFailure(int reason) {
                Toast.makeText(getApplicationContext(), "Couldn't connect to device!", Toast.LENGTH_SHORT).show();
Connect your IDE to all the code out there  Get Codota for Java