Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wake up Android Phone/tablet?

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!

like image 786
intINk Avatar asked Dec 20 '12 17:12

intINk


1 Answers

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();
like image 58
Xander Avatar answered Oct 03 '22 18:10

Xander