jpelgrim
2/7/2015 - 1:59 AM

Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and

Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your src/debug/ code and run it when the application or main activity starts. Apache 2.

/**
 * Show the activity over the lockscreen and wake up the device. If you launched the app manually
 * both of these conditions are already true. If you deployed from the IDE, however, this will
 * save you from hundreds of power button presses and pattern swiping per day!
 */
public static void riseAndShine(Activity activity) {
  activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);

  PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
  PowerManager.WakeLock lock =
      power.newWakeLock(FULL_WAKE_LOCK | ACQUIRE_CAUSES_WAKEUP | ON_AFTER_RELEASE, "wakeup!");
  lock.acquire();
  lock.release();
}