How to detect whether the phone is in sleep mode in the code?
<p>Is there any way to detect whether an android phone is in sleep mode (screen is black) in the code?
I wrote a home screen widget. I don't want the widget gets updated when the screen is black to save the battery consumption.</p>

<p>Thanks.</p>
