简体   繁体   English

从 Android 服务,如何确定屏幕是打开还是关闭

[英]From an Android service, how to determine whether screen WAS on or off

From an Android service (for example at onCreate time) how can I determine whether screen was on or off before receiving the first broadcast screen intent (that may never be triggered if screen was already off and user does not use its phone)?从 Android 服务(例如在 onCreate 时间)我如何才能在接收到第一个广播屏幕意图之前确定屏幕是打开还是关闭(如果屏幕已经关闭并且用户不使用它的手机,则可能永远不会触发)?

If you want to test if the screen is on, you can use http://developer.android.com/reference/android/os/PowerManager.html#isScreenOn ().如果要测试屏幕是否亮,可以使用http://developer.android.com/reference/android/os/PowerManager.html#isScreenOn ()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM