How to wake up Android with use adb - I want to wake up (if asleep) Android terminal before debugging every new version of application.
Typical flow is: 1. I do some changes in Eclipse. 2. In the meantime screen goes off or not. 3. I run "debug" and want force screen to wake up.
I found a method with "power key" emulation but it does not turn it on but rather toggles the power state. I do not want to add extra code to my application. What are the other methods to do such trivial task, please help.
Just use :
You can check device's current power state (including display) via adb with
dumpsys power
command and send the power key press event only if the display is off. The easier solution would be disabling the display timeout altogether "while connected to USB" in the Developer options.you could also add the following flags to your
onCreate()
in your main activity:This way your device should wake up when it is loaded onto the device through Eclipse.
if you execute
adb shell input keyevent KEYCODE_POWER
and gotKilled
, you should use root user by executesu
before.sleep:
(adb shell) input keyevent KEYCODE_SLEEP
wakeup:
(adb shell) input keyevent KEYCODE_WAKEUP
toggle:
(adb shell) input keyevent KEYCODE_POWER
I used the following to wake up remote devices for automated tests. If the screen isn't on, then it will press the power button followed by the menu button.
For Windows and Eclipse you can use .bat file:
It will check, if screen is off it will switch the power state. To use it with Eclipse this .bat file should be used as "External tool" (just fill the path to the .bat) and linked to the project in it's properties (Builders - Import - ).