Screen on

  • Replies:5
  • OpenNot stickiedUnanswered
  • Forum posts: 2

Apr 24, 2016 11:32:11 AM via Website

How can I know if the screen is turned on due to user's pressing power button or other event like incoming call? Thanks for your help.

  • Forum posts: 270

Apr 24, 2016 12:45:43 PM via Website

Welcome to AndroidPIT forum,

You need to register app as broadcast receiver for ACTION_SCREEN_ON event. Additional info can be found on Google Android Developers. If you will have any difficulties, our users will be happy to help you.

  • Forum posts: 2

Apr 24, 2016 1:26:58 PM via Website

Hi,

User's pressing power button and other events will trigger ACTION_SCREEN_ON event. How can I know if it is tiggered by user?

  • Forum posts: 270

Apr 24, 2016 2:52:06 PM via Website

What is your final target? Maybe there is an another simple way to get it than tracking Power button state. For security reasons using the power button by apps requires too many permission...

  • Forum posts: 208

Apr 25, 2016 2:57:21 PM via Website

IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
BroadcastReceiver mReceiver = new ScreenReceiver();
registerReceiver(mReceiver, filter);

  • Forum posts: 270

Apr 25, 2016 3:07:03 PM via Website

User's pressing power button and other events will trigger ACTION_SCREEN_ON event. How can I know if it is tiggered by user?

ACTION_SCREEN_OFF can be triggered not only by Power Button....