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, "vagner.android.CrashHandler.lock");
            lock.setReferenceCounted(true);
        } 
        return lock;
    } 
 
    public static synchronized void acquire(Context context) {
        WakeLock wakeLock = getLock(context);
        if (!wakeLock.isHeld()) {
            wakeLock.acquire();
        } 
    } 
 
    public static synchronized void release() { 
        if (lock != null) {
            if (lock.isHeld()) {
Contextual code suggestions in your IDE  Get Codota for Java