Wake up Android Phone/tablet?
Asked Answered
F

1

5

I've got a push notification-app, is there any way to wake up the screen (just make it light up) whenever I receive a push notification?

if you want some code just let me know! and Thank you for your answers!

Fulvi answered 20/12, 2012 at 17:27 Comment(1)
You shoudl use this tutorial developer.android.com/reference/android/os/PowerManager.html or use wake lock in andridFrancesco
C
15

You can do it using a WakeLock this way:

When you set your notification:

WakeLock screenOn = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "example");
screenOn.acquire();

And, IMPORTANT, release the wakelock when you don't need it anymore:

screenOn.release();
Cabral answered 20/12, 2012 at 17:44 Comment(3)
Remember about <uses-permission android:name="android.permission.WAKE_LOCK" />Premillennial
What about the now deprecated SCREEN_BRIGHT_WAKE_LOCK?Monia
How about if we want to skip security lock screens (PIN, Patterns etc)?Examine

© 2022 - 2024 — McMap. All rights reserved.