Android disable screen saver

后端 未结 2 631
醉话见心
醉话见心 2021-02-09 15:29

I\'d like to disable screen saver while my appliction is running. How it can be done? Where is the best place to disable / enable the screen saver? in the first activity? in the

2条回答
  •  余生分开走
    2021-02-09 16:12

    The wake lock permission must be specified in the manifest.

    
    

    Then in the activity use the following to keep the screen on while the activity is running.

    getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
    

    Remember that unnecessarily keeping the screen on unnecessarily drains power from the user's device.

提交回复
热议问题