4

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

Guillaume Perrot
  • 4,278
  • 3
  • 27
  • 37

1 Answers1

9

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

Nick Campion
  • 10,479
  • 3
  • 44
  • 58