本文介绍了唤醒Android手机/平板电脑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个推送通知应用程序,每当我收到推送通知时,有什么方法可以唤醒屏幕(只是使其亮起)?
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!
推荐答案您可以使用WakeLock通过以下方式进行操作:
You can do it using a WakeLock this way:
设置通知时:
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();更多推荐
唤醒Android手机/平板电脑?
发布评论