Code example for WifiP2pManager

Methods: connect

0
				String deviceDetails = (s.replace("Connect to ", "")).trim();
				String[] devDetails = deviceDetails.split(",");
				WifiP2pConfig config = new WifiP2pConfig();
				config.deviceAddress = devDetails[1];
				config.wps.setup = WpsInfo.PBC;
				manager.connect(channel, config, new ActionListener() {
 
					@Override 
					public void onSuccess() { 
						(Toast.makeText(context, "p2p connect success",
								Toast.LENGTH_SHORT)).show();
					} 
 
					@Override 
					public void onFailure(int reason) {
						(Toast.makeText(context,
								"p2p connect failed:" + reason,
								Toast.LENGTH_SHORT)).show();
					} 
				}); 
Connect your IDE to all the code out there  Get Codota for Java