Code example for WifiManager.WifiLock

Methods: acquire, setReferenceCounted

0
	 
	private void acquireWifiLock() { 
		if (mWifiLock == null) {
			WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
			mWifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL, TAG);
			mWifiLock.setReferenceCounted(false);
		} 
		mWifiLock.acquire();
	} 
	 
	private void releaseWifiLock() { 
		if (mWifiLock != null && mWifiLock.isHeld()) {
			mWifiLock.release();
		} else { 
			Log.e(TAG, this.getClass().getSimpleName()
					+ " had mismatched release wifi lock call"); 
		} 
	} 
	 
} 
Experience pair programming with AI  Get Codota for Java