Correct method for setKeepScreenOn / FLAG_KEEP_SCREEN_ON

后端 未结 5 1910
灰色年华
灰色年华 2020-12-02 16:10

I am using the method setKeepScreenOn(true) and haven\'t been able to figure out how to call this in relation to the current Activity (which has a content view set). I\'ve

5条回答
  •  臣服心动
    2020-12-02 16:30

    Try this answer:

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

    getWindow is a method defined for activities, and won't require you to find a View first.

提交回复
热议问题