Wake up Android with use adb or Eclipse (just before debug)?

后端 未结 9 620
温柔的废话
温柔的废话 2021-01-31 04:45

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 cha

相关标签:
9条回答
  • 2021-01-31 05:11

    you could also add the following flags to your onCreate() in your main activity:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    

    This way your device should wake up when it is loaded onto the device through Eclipse.

    0 讨论(0)
  • 2021-01-31 05:14

    Just use :

    adb shell input keyevent 26
    
    0 讨论(0)
  • 2021-01-31 05:14

    Here's what I came up with:

    adb shell dumpsys power | grep "mScreenOn=true" | xargs -0 test -z && adb shell input keyevent 26
    

    This will first check to see if the screen is on. If it isn't, it will emulate the power key, which will turn on the device's screen.

    0 讨论(0)
提交回复
热议问题