Example usage for android.os PowerManager PROXIMITY_SCREEN_OFF_WAKE_LOCK

List of usage examples for android.os PowerManager PROXIMITY_SCREEN_OFF_WAKE_LOCK

Introduction

In this page you can find the example usage for android.os PowerManager PROXIMITY_SCREEN_OFF_WAKE_LOCK.

Prototype

int PROXIMITY_SCREEN_OFF_WAKE_LOCK

To view the source code for android.os PowerManager PROXIMITY_SCREEN_OFF_WAKE_LOCK.

Click Source Link

Document

Wake lock level: Turns the screen off when the proximity sensor activates.

Usage

From source file:com.android.dialer.voicemail.VoicemailPlaybackPresenter.java

/**
 * Initialize variables which are activity-independent and state-independent.
 *//* w  ww. j  av  a  2s.  co  m*/
protected VoicemailPlaybackPresenter(Activity activity) {
    Context context = activity.getApplicationContext();
    mAsyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor();
    mVoicemailAudioManager = new VoicemailAudioManager(context, this);
    mVoicemailAsyncTaskUtil = new VoicemailAsyncTaskUtil(context.getContentResolver());
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (powerManager.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) {
        mProximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, TAG);
    }
}

From source file:org.awokenwell.proximity.ProximitySensorListener.java

/**
 *
 *///from  w ww . j a  v  a  2  s. c o  m
public void enableProximityScreenOff() {
    Log.d("ProximitySensorListener", "XXX enableProximityScreenOff");
    if (wakeLock != null) {
        wakeLock.release();
    }
    wakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
            ProximitySensorListener.this.toString());
    wakeLock.acquire();
}