Android: prevent display from turning off

前端 未结 4 1481
囚心锁ツ
囚心锁ツ 2021-01-02 10:05

I\'ve written a small game, that is only controlled via some sensors. There is no touchscreninput or something similar.

The problem is, that after a few seconds of g

4条回答
  •  星月不相逢
    2021-01-02 10:48

    use this code in the your game's Activity as first line in the onCreate() after the super call:

    this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    

    This will result in the System handling the screen for you.

    Best wishes, Tim

提交回复
热议问题