Code example for PowerManager.WakeLock

Methods: acquire, setReferenceCounted

0
 
		// create the new wakelock and put it into the map 
		final WakeLock newWakeLock = mgr.newWakeLock(flags, id.toString());
 
		// if this wakelock doesn't already exist, continue 
		locks.put(id, newWakeLock);
		// only one at a time? TODO 
		newWakeLock.setReferenceCounted(false);
 
		if (releaseAfterMs == 0) {
			newWakeLock.acquire();
		} else { 
			newWakeLock.acquire(releaseAfterMs);
		} 
	} 
 
	public static void release(String id) {
		final WakeLock wakeLock = locks.get(id);
		// if there is was a wakelock, release it. (it has to be held) 
		try { 
Stop searching for code, let great code find you!  Add Codota to your java IDE