what is the proper, non-deprecated way to wake up the device?

后端 未结 1 1434
傲寒
傲寒 2020-12-28 17:12

My requirement is: after a GCM message arrives, the device should wake up to display a high-priority notification. The device should turn the screen on.

Cu

相关标签:
1条回答
  • 2020-12-28 17:38

    Use the code I got from my question, and then just finish the activity, should leave the screen on for the users normal amount of time. Trust me this is the only way, after spending a good week on this problem. You could always set the activity to transparent with notitlebar, the user will never know.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
            WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
            WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        finish();
    }
    
    0 讨论(0)
提交回复
热议问题