Example usage for android.content Context POWER_SERVICE

List of usage examples for android.content Context POWER_SERVICE

Introduction

In this page you can find the example usage for android.content Context POWER_SERVICE.

Prototype

String POWER_SERVICE

To view the source code for android.content Context POWER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.PowerManager for controlling power management, including "wake locks," which let you keep the device on while you're running long tasks.

Usage

From source file:Main.java

public static boolean isScreenOn(Context context) {
    return ((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isScreenOn();
}

From source file:Main.java

public static boolean isScreenOn(Context ctx) {
    PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
    return pm.isScreenOn();
}

From source file:Main.java

public static boolean checkIsScreenOn(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return pm.isScreenOn();
}

From source file:Main.java

public static boolean isDisplayOn(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return powerManager.isScreenOn();
}

From source file:Main.java

public static final boolean isScreenOn(Context context) {
    PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return powerManager.isScreenOn();
}

From source file:Main.java

public static void wakeLockOn(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (wl == null)
        wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "CLOCK_ALARM");
    wl.acquire();/*w  w w .jav a  2 s  .  c o  m*/
}

From source file:Main.java

/**
 * return if screen on/*  ww  w .j  av a 2s .co  m*/
 * @param context
 * @return
 */
public static boolean isScreenOn(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    return pm.isScreenOn();
}

From source file:Main.java

public static void acquireWakeLock(Context context) {
    if (wakeLock == null) {
        PowerManager powerManager = (PowerManager) (context.getSystemService(Context.POWER_SERVICE));
        wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
        wakeLock.acquire();//from   ww  w.  j  a v  a  2s.com
    }
}

From source file:Main.java

public static void acquire(Context context) {
    if (wakeLock != null)
        wakeLock.release();//from w w w .j  a va2 s. c  o  m

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
            "WakeLock");
    wakeLock.acquire();
}

From source file:Main.java

public static void rebootRecovery(Context context) {
    Log.w(TAG, "!!! REBOOT RECOVERY !!!");
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    pm.reboot("recovery");
}