Using FLAG_SHOW_WHEN_LOCKED with disableKeyguard() in secured Android lock screen

后端 未结 5 1687
轻奢々
轻奢々 2021-01-30 11:33

The Context

Recently, I have been looking for reliable ways to control a secured Android Keyguard. Mainly to display a custom lock screen. I know that Google had state

5条回答
  •  一个人的身影
    2021-01-30 11:58

    I have used this with some success in both Gingerbread and ICS to open my activity (via a background service which is starting it). In the activity being started:

    @Override
    public void onAttachedToWindow() {
        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);
    }
    

提交回复
热议问题