Code example for PowerManager.WakeLock

Methods: setReferenceCounted

0
		if (lock == null) {
			PowerManager mgr = (PowerManager) context
					.getSystemService(Context.POWER_SERVICE);
 
			lock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "org.jtb.alogcat.lock");
			lock.setReferenceCounted(true);
		} 
		return lock;
	} 
 
	public static synchronized void acquire(Context context) {
		WakeLock wakeLock = getLock(context);
		if (!wakeLock.isHeld()) {
			wakeLock.acquire();
			Log.d("alogcat", "wake lock acquired");
		} 
	} 
 
	public static synchronized void release() { 
		if (lock == null) {
			Log