Android: Turn off screen from a service

旧巷老猫 提交于 2019-12-05 13:11:57

I see two options:

(1) Create a dummy Activity and use it to get a Window object through the getWindow(); method. Then you would use an Intent to call the screen off from your Service.

(2) Use IHardwareService.Stub. Not part of the SDK, but there's a workaround in this blog post: http://www.tutorialforandroid.com/2009/01/changing-screen-brightness.html

BTW: I would strongly recommend the first option. You never know when a class that is not part of the SDK might change.

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