Code example for PowerManager.WakeLock

Methods: acquire, hashCode, toString

0
     * @param intent 
     * @param wlTag 
     */ 
    public void acquirePartialWakeLock(Intent intent, String wlTag) {
        final WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, wlTag);
        wl.acquire();
        wakeLocks.add(wl);
        intent.putExtra(WakeLockManager.EXTRA_WAKELOCK_HASH, wl.hashCode());
        intent.putExtra(WakeLockManager.EXTRA_WAKELOCK_TAG, wlTag);
        log.d(wl.toString() + " " + wlTag + " was acquired");
    } 
 
    /** 
     * Releases a partial {@link WakeLock} with a tag contained in the given 
     * {@link Intent} 
     *  
     * @param intent 
     */ 
    public void releasePartialWakeLock(Intent intent) {
        if (intent.hasExtra(WakeLockManager.EXTRA_WAKELOCK_TAG)) {
            final int hash = intent.getIntExtra(WakeLockManager.EXTRA_WAKELOCK_HASH, -1);