Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get active flags on Android Window

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

like image 862
iGio90 Avatar asked Jun 13 '14 20:06

iGio90


1 Answers

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) ...
like image 118
matiash Avatar answered Oct 26 '22 16:10

matiash