29

is it possible to get programmatically which flags are currently active on a Window?

We can enable flags with:

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

Does api provides a way to get a list of currently active flags? Thanks

iGio90
  • 3,251
  • 7
  • 30
  • 43

1 Answers1

78

You can use:

int flags = getWindow().getAttributes().flags;

You can see it's used by the Window.setFlags() implementation:

public void setFlags(int flags, int mask) {
    final WindowManager.LayoutParams attrs = getAttributes();
    attrs.flags = (attrs.flags&~mask) | (flags&mask);
    ...

To determine if individual flags are set, you must use bitwise and. For example:

if ((flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) != 0) ...
matiash
  • 54,791
  • 16
  • 125
  • 154
  • 2
    yeah but it return me an int that doen't concern nthing... :S – iGio90 Jun 13 '14 at 22:18
  • 3
    @iGio90 the int contains all your flags. you just need bitwise operation to extract them. Edited the answer, check the example. – matiash Jun 13 '14 at 22:20