Peter Peter - 1 year ago 132
Android Question

How to detect when the screen will turn off?

Is it possible to detect when screen will turn off and catch it? I want to set timer for 15 seconds in global settings of Android. I am trying to find some information how to catch wake-lock mode.

Answer Source

Just register your app for the actions Intent.ACTION_SCREEN_OFF and Intent.ACTION_SCREEN_ON and do what you want when these events are broadcasted.

Create a dedicated BroadcastReceiver class (and add it to the manifest) or register a BroadcastReceiver at runtime.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download