0

I'm interesting in determine what caused a screen to turn on inside my app. I already know and utilize the ACTION_SCREEN_ON and USER_PRESENT broadcasts, but i can't seem to figure out how to determine why the screen turned on.

Was it because the user hit the power key? Perhaps a phone call came in, or a new text message arrived. Or perhaps some random app requested the screen to turn on.

I'm not interested in controlling when the screen turns on or off, just determining the reason behind it, so my app can respond accordingly.

Thanks in advance for your help

AAG
  • 235
  • 1
  • 11
  • hmm.. if you think about it, screen can only be turned off on power button pressed or it turns off auto after some time interval. So maybe you can check if the power button was pressed. Look at this post: [link](http://stackoverflow.com/a/10365166/3552945) – 633kM Feb 06 '16 at 17:09
  • I'm looking for why it turned on, not turned off. – AAG Feb 06 '16 at 17:30
  • oh sorry.. but the logic is the same: check if power button was pressed or if a call came in: [incomming call](http://stackoverflow.com/a/15564021/3552945) or message is recived: [message reciver](http://stackoverflow.com/a/7171785/3552945) (but a message don't turn your screen on).. well you can google everything what you can remember that turns your screen on.. i don't know better solution – 633kM Feb 06 '16 at 17:38
  • Can you catch power button presses like what is shown in your link from a service? My app may not be the active app – AAG Feb 08 '16 at 14:44

0 Answers0