0

I'm trying to create a service that run in background in android.. That service should work only when the device is on sleep (Means that screen is off)..

I think that can be done using a service but I don't know how to detect if the phone is awake or not.. Any Idea ? Thanks..

Muhammad Ashraf
  • 1,252
  • 1
  • 14
  • 32

1 Answers1

1

For screen on-off state, you can try with ACTION_SCREEN_ON and ACTION_SCREEN_OFF intents, as shown in this blog post:

http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/

From here : How to detect whether screen is on or off if API level is 4?

Community
  • 1
  • 1
Morteza Soleimani
  • 2,652
  • 3
  • 25
  • 44