Code example for WifiManager

Methods: addNetworkenableNetwork

0
		// wifiConfig.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); 
		// wifiConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); 
		wifiConfig.status = WifiConfiguration.Status.ENABLED;
		// try to connect 
		WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		int netId = wifi.addNetwork(wifiConfig);
		boolean res = wifi.enableNetwork(netId, true);
		Toast.makeText(this, "Connected " + res, Toast.LENGTH_LONG).show();
	} 
 
	@Override 
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{ 
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_CANCELED)
			return; 
 
		if (requestCode == SCAN_QR_REQUEST)
		{ 
			try 
			{