Code example for WifiManager

Methods: createWifiLock

0
		WifiManager wm = (WifiManager) context
				.getSystemService(Context.WIFI_SERVICE);
		/* 
		 * We want WifiManager.WIFI_MODE_FULL as we're not just scanning 
		 */ 
		wifilock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL,
				context.toString());
	} 
 
	public void lock(final boolean state) {
		if (state) {
			if (!wifilock.isHeld()) {
				wifilock.acquire();
				onAcquire(); 
			} 
		} else if (wifilock.isHeld()) {
			wifilock.release();
			onRelease(); 
		} 
	}