Wake up Android Phone/tablet?

≡放荡痞女 提交于 2019-11-30 08:41:56

问题


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!


回答1:


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();


来源:https://stackoverflow.com/questions/13977448/wake-up-android-phone-tablet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!