Search code examples
androidscreenandroid-activityfullscreen

which is better add flag or set flag regard full screen and screen on


I wonder which is better in performance and behavior between the following ways in achieving:

  1. Full Screen.

  2. Screen On.

or both is the same

First:

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

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
            WindowManager.LayoutParams.FLAG_FULLSCREEN); 

OR

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

MAYBE this is easy question but I'm still learning android development,

Any help will be appreciated,

Thanks.


Solution

  • I don't think both scenarios affect performance a lot, but in modern developing environment we prefer simplicity of coding which directly seen in

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

    so definitely I vote for that