Skip to content Skip to sidebar Skip to footer

Turn On Screen On Device

How can I turn the sceen on ? I tried something like this adb -d shell am broadcast -a android.intent.action.SCREEN_ON It really should work, I send broadcast intent it is receiv

Solution 1:

adb shell input keyevent KEYCODE_POWER

Works to turn on screen (when display is off) Works to turn off screen (when display is on/awake)

Solution 2:

For Android 5.0 and above:

adb shell input keyevent KEYCODE_WAKEUP

or

adb shell input keyevent 224
KEYCODE_WAKEUP

Key code constant: Wakeup key. Wakes up the device. Behaves somewhat like KEYCODE_POWER but it has no effect if the device is already awake.

https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_WAKEUP


Solution 3:

u can turn it on/off if u do like:

adb shell
@shell: input keyevent 26
@shell: (enter or via hidden command empty line)
@shell: exit

this worked for me on some android versions ;)(NOTE: this will turn the screen on and off, depends on the actual screen state)

To detect the current state of the screen u can use the following ways:Android < 5.x.xadb shell dumpsys input_methodIn the output search for mScreenOn=true/false Android >= 5.x.xadb shell dumpsys displayIn the output search for mScreenState=ON/OFF

In my scripts i use this \s{0,}mScreen(State|On)=(?<STATE>(true|false|on|off))\s{0,} (Compiled|IgnoreCase|ExplicitCapture) regular expression for both outputs to detect the current state.

EDIT (16.03.2018):

There is also another way to detect the screen state, it works since Android 3.0. The dumpsys window policy command will give us all we need. - In the output search for mScreenOn(Fully)?=(?<STATE>(true|false)). There are also other useful informations like:

  • mUnrestrictedScreen (value is like: (0,0) 768x1280)
  • mRestrictedScreen (value is like: (0,0) 768x1184)

Regards,

k1ll3r8e

Solution 4:

I could be wrong about this, but...

You shouldn't think of broadcasts as something to send to get things done, but instead think of them as things that are sent when things are done.

I think the system sends 'android.intent.action.SCREEN_ON' when screen is goes on, but sending 'android.intent.action.SCREEN_ON' does not necessarily make the screen go on.

I hope this makes sense.

For the answer, you can find it in...

Solution 5:

The command to toggle the screen on/off is:

adb shell input keyevent 26

This condensed command is preferred because it allows you to use it in scripts.

Cheers!

Post a Comment for "Turn On Screen On Device"