App锁屏显示

清单文件申请权限


    
    
    
    

添加到activity onCreate的setContentView(); 前

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(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//打开屏幕
        );
        setContentView(R.layout.activity_close);
        initView();
        
    }

你可能感兴趣的:(App锁屏显示)