Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个推送通知应用程序,有什么方法可以在我收到推送通知时唤醒屏幕(让它亮起来)?
如果您想要一些代码,请告诉我!并感谢您的回答!
您可以使用WakeLock以下方式执行此操作:
WakeLock
当您设置通知时:
WakeLock screenOn = ((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "example"); screenOn.acquire();
而且,重要的是,当您不再需要它时释放唤醒锁:
screenOn.release();