Code example for PowerManager.WakeLock

Methods: isHeld, release

0
			if (service.getServiceOffInterval() > service.getServiceError()) {
				service.getHandler().postDelayed(new Runnable() {
					@Override 
					public void run() { 
						// if lock is not anymore held 
						if (lock.isHeld()) {
							lock.release();
							locationManager.removeUpdates(service);
						} 
					} 
				}, service.getServiceError());
			} 
		} catch (RuntimeException e) {
			e.printStackTrace();
		} 
	} 
 
	}