简体   繁体   中英

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)?

If you want to test if the screen is on, you can use http://developer.android.com/reference/android/os/PowerManager.html#isScreenOn ().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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