简体   繁体   English

如何检测照明解锁和后台屏幕解锁

[英]How to detect light-up unlock and unlock of the screen in background

I am working on an android app trying to record the usage of the phone. 我正在尝试记录手机的使用情况的android应用程序。 For one function, I am trying to detect whether the screen is light up (not necessary to be unlocked), unlock and lock. 对于一种功能,我正在尝试检测屏幕是否亮起(不必解锁),解锁并锁定。 How can I capture this three kinds of behavior of user? 如何捕获用户的这三种行为?

Thanks! 谢谢!

Register a BroadcastReceiver 注册BroadcastReceiver
Use Intent.ACTION_SCREEN_OFF and ACTION_SCREEN_ON to detect screen on/off event Guideline about how to use BroadcastReceiver can be found here https://developer.android.com/guide/components/broadcasts.html 使用Intent.ACTION_SCREEN_OFF和ACTION_SCREEN_ON来检测屏幕开/关事件指南,有关如何使用BroadcastReceiver的指南,请参见https://developer.android.com/guide/components/broadcasts.html

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

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