当我的活动将以编程方式启动时如何解锁设备?
当发生任何警报时服务启动活动时,我面临一个有关解锁设备的问题。 场景是:
我的应用程序有活动和服务,所有活动在启动时都会向服务注册。 服务将使用 WiFi 建立与服务器的连接,当服务器发送任何警报时,我的应用程序必须启动一项活动来向用户更新发生了一些警报,现在的问题是当设备进入睡眠模式并且屏幕变暗时当任何警报生成时,设备将在这种情况下被锁定,然后我必须解锁屏幕,并且屏幕亮度应恢复为活动状态,然后需要启动活动,但我无法解锁屏幕并重新获得启动活动时的屏幕亮度。
请帮助我用正确的代码示例解决这个问题。
问候, 皮克斯
I am facing one problem regarding unlocking the device when Service launched activity when any alarm occurs.
Scenario is :
My application is having activities and service and all activities will get register with service when it gets launched.
Service will establish the connection to the server using WiFi, and when server will send any alarm my application has to launch one activity to update to the User that there is some alarm occurs, Now problem is when Device goes to sleep mode and screen becomes dark and device will get locked in that situation when any alarm generates then I have to unlock the screen and screen brightness should regain as it was in active state and then need to launch the activity, but i failed to unlock the screen as well as regain the brightness of the screen while launching the activity.
Please help me to solve this issue with proper code example.
Regards,
Piks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用 PowerManager.WakeLock 类
You should use PowerManager.WakeLock class