how to wakeup android phone from sleep?

前端 未结 3 1347
情深已故
情深已故 2021-02-20 14:16

How to wakeup android phone from sleep (suspend to mem) programmably? I don\'t want to acquire any wakelock, which means the phone goes into \"real\" sleep with the cpu disabled

3条回答
  •  被撕碎了的回忆
    2021-02-20 15:04

    In order to let the Activity wake up the device and not require a password/swipe, you only need to add a few flags. To get that, include to your code:

    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
        WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
        WindowManager.LayoutParams.FLAG_FULLSCREEN |
        WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
        WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    

    This will wake up your App activity.

提交回复
热议问题