2

Explanation in the documentation:

  • flags int: The new window flags
  • mask int: Which of the window flag bits to modify.

I'm just trying to set the full screen when the activity is loaded by using getWindow().setFlag(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)

It works but I just don't understand the meaning behind the method's parameters. I'm thinking that flags is the look I want for the current window, but I don't know what mask does and why is it identical to flags

Vincent
  • 25
  • 1
  • 4
  • https://developer.android.com/reference/android/view/Window.html go to constant – Raj Jul 13 '17 at 05:22
  • The accepted answer is OK. But I think this one is even better: https://stackoverflow.com/a/47854714/2816119 specially this part: "The math is basically ((getFlags &~mask) | (value & mask))" – juangalf Apr 06 '22 at 23:14

1 Answers1

2

If you would have googled, you could have found this page, which can explain to you the idea of a mask. Basically is a bit-wise filter against another value. Very common when coding C and C++ for example, less in Java, almost not used anymore when coding Android, but of course still used by the system because are very fast operations (at the bits level). Using a mask which is the same as the value, means no filtering. You can accomplish the very same with other masks as well, of course.

Alessio
  • 3,063
  • 1
  • 15
  • 17
  • Thank you for your quick response. However, I think I've stated my question unclear. I'm not asking what a mask is or what it generally does. I was confused by how the 2 parameters in the method setFlags() are always identical. Thus, I don't know what the "mask" parameter does in this method (I know that the "flags" parameter would be the state I want the window to be in). – Vincent Jul 13 '17 at 05:34
  • I thought this answer that part: "Using a mask which is the same as the value, means no filtering.". Let me repeat it: it does nothing. – Alessio Jul 13 '17 at 05:36
  • Oh my bad. I kept reading the article page you gave and forgot to read the last part of your comment. Thank you! It makes more sense now – Vincent Jul 13 '17 at 05:38
  • 1
    If you look at the implementation, this is how they are filtered: _flags&mask_. – Alessio Jul 13 '17 at 05:38
  • You're welcome! I think this was a very good curious question, worth to answer :) – Alessio Jul 13 '17 at 05:40