Skip to content

Instantly share code, notes, and snippets.

@JosiasSena
Created July 15, 2016 23:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosiasSena/a60b327bcafe4aed13f5d05c79ceb0ee to your computer and use it in GitHub Desktop.
Save JosiasSena/a60b327bcafe4aed13f5d05c79ceb0ee to your computer and use it in GitHub Desktop.
Wakes up device/turns on screen. For example if a notification is received this will make sure that the devices screen lights up
public static void wakeUpPhone(Context context, String tag) {
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock((
PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.FULL_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP), tag);
wakeLock.acquire();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment