Code example for WifiManager.WifiLock

Methods: acquire

0
		// Display a notification about us starting. We put an icon in the 
		// status bar. 
		showNotification(); 
		 
		mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "mylock");
		mWifiLock.acquire();
	} 
 
	@Override 
	public int onStartCommand(Intent intent, int flags, int startId) {
		// We want this service to continue running until it is explicitly 
		// stopped, so return sticky. 
		return START_STICKY;
	} 
 
	@Override 
	public void onDestroy() { 
		// Cancel the persistent notification. 
		mNotificationManager.cancel(NOTIFICATION);
		 
		mWifiLock.release();