Code example for WifiManager.WifiLock

Methods: acquire, isHeld, setReferenceCounted

0
		WifiManager wman = (WifiManager) service.getSystemService(Context.WIFI_SERVICE);
		if(wifiLock == null) {
			wifiLock = wman.createWifiLock( 
							WifiManager.WIFI_MODE_FULL, 
							"com.testsipclient.InCallLock"); 
			wifiLock.setReferenceCounted(false);
		} 
		WifiInfo winfo = wman.getConnectionInfo();
		if(winfo != null) {
			DetailedState dstate = WifiInfo.getDetailedStateOf(winfo.getSupplicantState());
			//We assume that if obtaining ip addr, we are almost connected so can keep wifi lock 
			if(dstate == DetailedState.OBTAINING_IPADDR || dstate == DetailedState.CONNECTED) {
				if(!wifiLock.isHeld()) {
					wifiLock.acquire();
				} 
			} 
			 
			//This wake lock purpose is to prevent PSP wifi mode  
			 
				if(screenLock == null) {
Stop searching for code, let great code find you!  Add Codota to your java IDE