Disable keep screen on

后端 未结 4 1488
难免孤独
难免孤独 2020-12-02 21:44

I used:

getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

How do I resume to Default state (no-keep-on)?

4条回答
  •  孤城傲影
    2020-12-02 22:26

    Another approach

    getWindow().setFlags(this.getWindow().getFlags() & ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    

    Also read this

    and you can also set android:keepScreenOn="true" in the root View in xml.

提交回复
热议问题