Code example for WifiP2pManager

Methods: connect

0
     */ 
	public void connectToDevice(WifiP2pDevice device) {
		WifiP2pConfig config = new WifiP2pConfig();
		config.deviceAddress = device.deviceAddress;
		 
		manager.connect(channel, config, new ActionListener() {
			 
			@Override 
			public void onSuccess() { 
                Toast.makeText(getApplicationContext(), "Connected to Device!", Toast.LENGTH_SHORT).show();
                Log.d(MyApplication.this.TAG, "Device Connected!");
                 
                for(OnDeviceConnectedListener listener : deviceConnectedListeners) {
                	listener.onDeviceConnected();
                } 
			} 
			 
			@Override 
			public void onFailure(int reason) {
                Toast.makeText(getApplicationContext(), "Couldn't connect to device!", Toast.LENGTH_SHORT).show();
                Log.d(MyApplication.this.TAG, "Device Connection Failed!");