Android Galaxy S4 — Activity that is visible over lock screen

前端 未结 5 1030
一整个雨季
一整个雨季 2020-12-09 05:08

A few years ago, I wrote an alarm app that worked on Android 2, and I\'m now trying to upgrade it to work on Android 4. Specifically, on the Samsung Galaxy S4.

On A

5条回答
  •  难免孤独
    2020-12-09 05:53

    One of the questions you linked to has an answer that appeared to solve this issue for me.

    This is the code I am using which appears to be working:

    @Override
    public void onAttachedToWindow() {
            Window window = getWindow();
    
            window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
            super.onAttachedToWindow();
        }
    

    I'm also explicitly declaring this in the activity definition in the manifest:

    
    

    Android activity over default lock screen

提交回复
热议问题