Code example for WifiManager.WifiLock

Methods: acquire, setReferenceCounted

0
	public void startSampling(long samplingRate) {
		Log.e(LOG_TAG, "startSampling");
		setSamplingRate(samplingRate);
 
		wifiLock = wifiService.createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, "WifiAdapter lock"); 
		wifiLock.setReferenceCounted(false); 
        wifiLock.acquire(); 
		 
		wifiHandler.post(new ScanTask());
	} 
 
	@Override 
	public void stopSampling() { 
		 
		context.unregisterReceiver(wifiReceiver);
		wifiLock.release();
		 
	} 
 
	class ScanTask implements Runnable {