Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MarkoMilos
Forked from JakeWharton/gist:f50f3b4d87e57d8e96e9
Last active November 21, 2015 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkoMilos/28df4f290ba48fd4c03e to your computer and use it in GitHub Desktop.
Save MarkoMilos/28df4f290ba48fd4c03e to your computer and use it in GitHub Desktop.
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!
/**
* 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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment